@@ -76,8 +76,12 @@ public NextVersion FindVersion()
7676 var hasPreReleaseTag = semver . PreReleaseTag ? . HasTag ( ) == true ;
7777 var tag = configuration . Value . Tag ;
7878 var branchConfigHasPreReleaseTagConfigured = ! tag . IsNullOrEmpty ( ) ;
79- var preReleaseTagDoesNotMatchConfiguration = hasPreReleaseTag && branchConfigHasPreReleaseTagConfigured && semver . PreReleaseTag ? . Name != tag ;
80- if ( semver . PreReleaseTag ? . HasTag ( ) != true && branchConfigHasPreReleaseTagConfigured || preReleaseTagDoesNotMatchConfiguration )
79+ var branchConfigIsMainlineAndHasEmptyPreReleaseTagConfigured = configuration . Value . IsMainline && tag . IsEmpty ( ) ;
80+ var preReleaseTagDoesNotMatchConfiguration = hasPreReleaseTag
81+ && ( branchConfigHasPreReleaseTagConfigured || branchConfigIsMainlineAndHasEmptyPreReleaseTagConfigured )
82+ && semver . PreReleaseTag ? . Name != tag ;
83+ var preReleaseTagOnlyInBranchConfig = ! hasPreReleaseTag && branchConfigHasPreReleaseTagConfigured ;
84+ if ( preReleaseTagOnlyInBranchConfig || preReleaseTagDoesNotMatchConfiguration )
8185 {
8286 UpdatePreReleaseTag ( configuration . Value , semver , baseVersion . BranchNameOverride ) ;
8387 }
@@ -93,6 +97,12 @@ public NextVersion FindVersion()
9397 {
9498 // set the commit count on the tagged ver
9599 taggedSemanticVersion . BuildMetaData . CommitsSinceVersionSource = semver . BuildMetaData ? . CommitsSinceVersionSource ;
100+
101+ // set the updated prerelease tag when it doesn't match with prerelease tag defined in branch configuration
102+ if ( preReleaseTagDoesNotMatchConfiguration )
103+ {
104+ taggedSemanticVersion . PreReleaseTag = semver . PreReleaseTag ;
105+ }
96106 }
97107 }
98108
@@ -112,6 +122,12 @@ private void UpdatePreReleaseTag(EffectiveConfiguration configuration, SemanticV
112122 {
113123 var tagToUse = configuration . GetBranchSpecificTag ( this . log , Context . CurrentBranch . Name . Friendly , branchNameOverride ) ;
114124
125+ if ( configuration . IsMainline && tagToUse . IsEmpty ( ) )
126+ {
127+ semanticVersion . PreReleaseTag = new SemanticVersionPreReleaseTag ( tagToUse , null ) ;
128+ return ;
129+ }
130+
115131 long ? number = null ;
116132
117133 var lastTag = this . repositoryStore
0 commit comments