@@ -76,8 +76,12 @@ public NextVersion FindVersion()
76
76
var hasPreReleaseTag = semver . PreReleaseTag ? . HasTag ( ) == true ;
77
77
var tag = configuration . Value . Tag ;
78
78
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 )
81
85
{
82
86
UpdatePreReleaseTag ( configuration . Value , semver , baseVersion . BranchNameOverride ) ;
83
87
}
@@ -93,6 +97,12 @@ public NextVersion FindVersion()
93
97
{
94
98
// set the commit count on the tagged ver
95
99
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
+ }
96
106
}
97
107
}
98
108
@@ -112,6 +122,12 @@ private void UpdatePreReleaseTag(EffectiveConfiguration configuration, SemanticV
112
122
{
113
123
var tagToUse = configuration . GetBranchSpecificTag ( this . log , Context . CurrentBranch . Name . Friendly , branchNameOverride ) ;
114
124
125
+ if ( configuration . IsMainline && tagToUse . IsEmpty ( ) )
126
+ {
127
+ semanticVersion . PreReleaseTag = new SemanticVersionPreReleaseTag ( tagToUse , null ) ;
128
+ return ;
129
+ }
130
+
115
131
long ? number = null ;
116
132
117
133
var lastTag = this . repositoryStore
0 commit comments