File tree Expand file tree Collapse file tree 7 files changed +60
-3
lines changed
VersionCalculation/BaseVersionCalculators Expand file tree Collapse file tree 7 files changed +60
-3
lines changed Original file line number Diff line number Diff line change 1
- namespace GitVersionCore . Tests . VersionCalculation . Strategies
1
+ namespace GitVersionCore . Tests
2
2
{
3
3
using GitVersion ;
4
4
using LibGit2Sharp ;
@@ -20,6 +20,15 @@ public GitVersionContextBuilder WithConfig(Config config)
20
20
return this ;
21
21
}
22
22
23
+ public GitVersionContextBuilder WithTaggedMaster ( )
24
+ {
25
+ repository = CreateRepository ( ) ;
26
+ var target = repository . Head . Tip ;
27
+ ( ( MockTagCollection ) repository . Tags ) . Add ( new MockTag ( "1.0.0" , target ) ) ;
28
+ ( ( MockBranch ) repository . Head ) . Add ( new MockCommit { CommitterEx = SignatureBuilder . SignatureNow ( ) } ) ;
29
+ return this ;
30
+ }
31
+
23
32
public GitVersionContext Build ( )
24
33
{
25
34
return new GitVersionContext ( repository ?? CreateRepository ( ) , config ?? new Config ( ) ) ;
@@ -34,6 +43,7 @@ IRepository CreateRepository()
34
43
{
35
44
mockBranch
36
45
} ,
46
+ Tags = new MockTagCollection ( ) ,
37
47
Head = mockBranch
38
48
} ;
39
49
Original file line number Diff line number Diff line change 117
117
<Compile Include =" VariableProviderTests.cs" />
118
118
<Compile Include =" VersionCalculation\BaseVersionCalculatorTests.cs" />
119
119
<Compile Include =" VersionCalculation\Strategies\ConfigNextVersionBaseVersionStrategyTests.cs" />
120
- <Compile Include =" VersionCalculation\Strategies\GitVersionContextBuilder.cs" />
120
+ <Compile Include =" GitVersionContextBuilder.cs" />
121
+ <Compile Include =" VersionCalculation\Strategies\LastTagBaseVersionStrategyTests.cs" />
121
122
<Compile Include =" VersionCalculation\Strategies\MergeMessageBaseVersionStrategyTests.cs" />
122
123
</ItemGroup >
123
124
<ItemGroup >
Original file line number Diff line number Diff line change @@ -15,6 +15,15 @@ public override GitObject Target
15
15
get { return TargetEx ; }
16
16
}
17
17
public TagAnnotation AnnotationEx ;
18
+
19
+ public MockTag ( ) { }
20
+
21
+ public MockTag ( string name , Commit target )
22
+ {
23
+ NameEx = name ;
24
+ TargetEx = target ;
25
+ }
26
+
18
27
public override TagAnnotation Annotation
19
28
{
20
29
get { return AnnotationEx ; }
Original file line number Diff line number Diff line change 3
3
using GitVersion ;
4
4
using GitVersion . VersionCalculation ;
5
5
using GitVersion . VersionCalculation . BaseVersionCalculators ;
6
- using GitVersionCore . Tests . VersionCalculation . Strategies ;
7
6
using NUnit . Framework ;
8
7
using Shouldly ;
9
8
Original file line number Diff line number Diff line change
1
+ namespace GitVersionCore . Tests . VersionCalculation . Strategies
2
+ {
3
+ using GitVersion . VersionCalculation . BaseVersionCalculators ;
4
+ using NUnit . Framework ;
5
+ using Shouldly ;
6
+
7
+ [ TestFixture ]
8
+ public class LastTagBaseVersionStrategyTests
9
+ {
10
+ [ Test ]
11
+ public void ShouldAllowVersionIncremenet ( )
12
+ {
13
+ var context = new GitVersionContextBuilder ( )
14
+ . WithTaggedMaster ( )
15
+ . Build ( ) ;
16
+ var sut = new LastTagBaseVersionStrategy ( ) ;
17
+
18
+ var baseVersion = sut . GetVersion ( context ) ;
19
+
20
+ baseVersion . ShouldIncrement . ShouldBe ( true ) ;
21
+ }
22
+ }
23
+ }
Original file line number Diff line number Diff line change 90
90
<Compile Include =" VersionCalculation\BaseVersionCalculator.cs" />
91
91
<Compile Include =" VersionCalculation\BaseVersionCalculators\BaseVersion.cs" />
92
92
<Compile Include =" VersionCalculation\BaseVersionCalculators\ConfigNextVersionBaseVersionStrategy.cs" />
93
+ <Compile Include =" VersionCalculation\BaseVersionCalculators\LastTagBaseVersionStrategy.cs" />
93
94
<Compile Include =" VersionCalculation\BaseVersionCalculators\MergeMessageBaseVersionStrategy.cs" />
94
95
<Compile Include =" VersionCalculation\BaseVersionStrategy.cs" />
95
96
<Compile Include =" VersioningModes\ContinuousDeliveryMode.cs" />
Original file line number Diff line number Diff line change
1
+ namespace GitVersion . VersionCalculation . BaseVersionCalculators
2
+ {
3
+ public class LastTagBaseVersionStrategy : BaseVersionStrategy
4
+ {
5
+ public override BaseVersion GetVersion ( GitVersionContext context )
6
+ {
7
+ VersionTaggedCommit version ;
8
+ if ( new LastTaggedReleaseFinder ( context ) . GetVersion ( out version ) )
9
+ return new BaseVersion ( true , version . SemVer ) ;
10
+
11
+ return null ;
12
+ }
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments