@@ -44,66 +44,74 @@ public virtual NextVersion FindVersion()
4444 }
4545
4646 var nextVersion = Calculate ( Context . CurrentBranch , Context . Configuration ) ;
47- var baseVersion = nextVersion . BaseVersion ;
4847
49- SemanticVersion semver ;
48+ SemanticVersion semanticVersion ;
5049 if ( nextVersion . Configuration . VersioningMode == VersioningMode . Mainline )
5150 {
52- semver = this . mainlineVersionCalculator . FindMainlineModeVersion ( baseVersion ) ;
51+ semanticVersion = this . mainlineVersionCalculator . FindMainlineModeVersion ( nextVersion ) ;
5352 }
5453 else
5554 {
56- ////
57- // TODO: Please do a refactoring and move the logic from IMainlineVersionCalculator::CreateVersionBuildMetaData to some where else (Reason: Separation of concern violation).
58- var baseVersionBuildMetaData = this . mainlineVersionCalculator . CreateVersionBuildMetaData ( baseVersion . BaseVersionSource ) ;
59- //
55+ semanticVersion = FindOtherModeVersion ( nextVersion ) ;
56+ }
57+
58+ if ( semanticVersion . CompareTo ( Context . CurrentCommitTaggedVersion ) == 0 )
59+ {
60+ // Will always be 0, don't bother with the +0 on tags
61+ semanticVersion . BuildMetaData . CommitsSinceTag = null ;
62+ }
63+
64+ return new ( semanticVersion , nextVersion . BaseVersion , new ( nextVersion . Branch , nextVersion . Configuration ) ) ;
65+ }
66+
67+ private SemanticVersion FindOtherModeVersion ( NextVersion nextVersion )
68+ {
69+ ////
70+ // TODO: Please do a refactoring and move the logic from IMainlineVersionCalculator::CreateVersionBuildMetaData to some where else (Reason: Separation of concern violation).
71+ var baseVersionBuildMetaData = this . mainlineVersionCalculator . CreateVersionBuildMetaData (
72+ nextVersion . BaseVersion . BaseVersionSource
73+ ) ;
74+ //
75+
76+ ////
77+ // TODO: We need to decide whether or not to calculate the upcoming semantic version or the previous one because of tagging. Actually this should be part of the branch configuration system.
78+ var takeIncrementedVersion = baseVersionBuildMetaData . Sha != nextVersion . BaseVersion . BaseVersionSource ? . Sha ;
79+ takeIncrementedVersion |= nextVersion . Configuration . IsReleaseBranch ;
80+ takeIncrementedVersion |= nextVersion . Branch . Name . WithoutOrigin . StartsWith ( "develop" ) ;
81+ //
6082
83+ if ( takeIncrementedVersion )
84+ {
6185 ////
62- // TODO: We need to decide whether or not to calculate the upcoming semantic version or the previous one because of tagging. Actually this should be part of the branch configuration system.
63- var takeIncrementedVersion = baseVersionBuildMetaData . Sha != nextVersion . BaseVersion . BaseVersionSource ? . Sha ;
64- takeIncrementedVersion |= nextVersion . Configuration . IsReleaseBranch ;
65- takeIncrementedVersion |= nextVersion . Branch . Name . WithoutOrigin . StartsWith ( "develop" ) ;
86+ // TODO: We need to consider somehow the IGitVersionConfiguration::Ignore property here!!
87+ var semanticVersionWithTag = this . repositoryStore . GetTaggedSemanticVersionsOnBranch (
88+ nextVersion . Branch , Context . Configuration . LabelPrefix , Context . Configuration . SemanticVersionFormat
89+ ) . FirstOrDefault ( ) ;
6690 //
6791
68- if ( takeIncrementedVersion )
92+ if ( semanticVersionWithTag ? . Value . CompareTo ( nextVersion . IncrementedVersion , false ) > 0 )
6993 {
70- ////
71- // TODO: We need to consider somehow the IGitVersionConfiguration::Ignore property here!!
72- var semanticVersionWithTag = this . repositoryStore . GetTaggedSemanticVersionsOnBranch (
73- nextVersion . Branch , Context . Configuration . LabelPrefix , Context . Configuration . SemanticVersionFormat
74- ) . FirstOrDefault ( ) ;
75- //
76-
77- if ( semanticVersionWithTag ? . Value . CompareTo ( nextVersion . IncrementedVersion , false ) > 0 )
94+ return new SemanticVersion ( semanticVersionWithTag . Value )
7895 {
79- semver = new SemanticVersion ( semanticVersionWithTag . Value )
80- {
81- PreReleaseTag = new SemanticVersionPreReleaseTag ( nextVersion . IncrementedVersion . PreReleaseTag ) ,
82- BuildMetaData = baseVersionBuildMetaData
83- } ;
84- }
85- else
86- semver = new SemanticVersion ( nextVersion . IncrementedVersion )
87- {
88- BuildMetaData = baseVersionBuildMetaData
89- } ;
96+ PreReleaseTag = new SemanticVersionPreReleaseTag ( nextVersion . IncrementedVersion . PreReleaseTag ) ,
97+ BuildMetaData = baseVersionBuildMetaData
98+ } ;
9099 }
91100 else
92101 {
93- semver = new SemanticVersion ( baseVersion . SemanticVersion )
102+ return new SemanticVersion ( nextVersion . IncrementedVersion )
94103 {
95104 BuildMetaData = baseVersionBuildMetaData
96105 } ;
97106 }
98107 }
99-
100- if ( semver . CompareTo ( Context . CurrentCommitTaggedVersion ) == 0 )
108+ else
101109 {
102- // Will always be 0, don't bother with the +0 on tags
103- semver . BuildMetaData . CommitsSinceTag = null ;
110+ return new SemanticVersion ( nextVersion . BaseVersion . SemanticVersion )
111+ {
112+ BuildMetaData = baseVersionBuildMetaData
113+ } ;
104114 }
105-
106- return new ( semver , baseVersion , new ( nextVersion . Branch , nextVersion . Configuration ) ) ;
107115 }
108116
109117 private NextVersion Calculate ( IBranch branch , IGitVersionConfiguration configuration )
@@ -211,11 +219,11 @@ IEnumerable<NextVersion> GetNextVersionsInternal()
211219 log . Info ( "Using current branch name to calculate version tag" ) ;
212220
213221 var incrementedVersion = GetIncrementedVersion ( effectiveConfiguration , baseVersion , label ) ;
214- if ( effectiveConfiguration . Value . VersioningMode == VersioningMode . Mainline
215- && incrementedVersion . PreReleaseTag . HasTag ( ) )
216- {
217- continue ;
218- }
222+ // if (effectiveConfiguration.Value.VersioningMode == VersioningMode.Mainline
223+ // && incrementedVersion.PreReleaseTag.HasTag())
224+ // {
225+ // continue;
226+ // }
219227
220228 if ( incrementedVersion . IsMatchForBranchSpecificLabel ( label ) )
221229 {
0 commit comments