@@ -130,16 +130,15 @@ public void PrepareRelease(string projectDirectory, string releaseUnstableTag =
130130
131131 var releaseBranchName = this . GetReleaseBranchName ( versionOptions ) ;
132132 var originalBranchName = repository . Head . FriendlyName ;
133+ var releaseVersion = string . IsNullOrEmpty ( releaseUnstableTag )
134+ ? versionOptions . Version . WithoutPrepreleaseTags ( )
135+ : versionOptions . Version . SetFirstPrereleaseTag ( releaseUnstableTag ) ;
133136
134137 // check if the current branch is the release branch
135138 if ( string . Equals ( originalBranchName , releaseBranchName , StringComparison . OrdinalIgnoreCase ) )
136139 {
137- this . stdout . WriteLine ( $ "Current branch '{ releaseBranchName } ' is a release branch. Updating version...") ;
138- this . UpdateVersion ( projectDirectory , repository ,
139- version =>
140- string . IsNullOrEmpty ( releaseUnstableTag )
141- ? version . WithoutPrepreleaseTags ( )
142- : version . SetFirstPrereleaseTag ( releaseUnstableTag ) ) ;
140+ this . stdout . WriteLine ( $ "{ releaseBranchName } branch advanced from { versionOptions . Version } to { releaseVersion } .") ;
141+ this . UpdateVersion ( projectDirectory , repository , versionOptions . Version , releaseVersion ) ;
143142 return ;
144143 }
145144
@@ -151,27 +150,21 @@ public void PrepareRelease(string projectDirectory, string releaseUnstableTag =
151150 }
152151
153152 // create release branch and update version
154- this . stdout . WriteLine ( $ "Creating release branch '{ releaseBranchName } '...") ;
155153 var releaseBranch = repository . CreateBranch ( releaseBranchName ) ;
156154 Commands . Checkout ( repository , releaseBranch ) ;
157- this . UpdateVersion ( projectDirectory , repository ,
158- version =>
159- string . IsNullOrEmpty ( releaseUnstableTag )
160- ? version . WithoutPrepreleaseTags ( )
161- : version . SetFirstPrereleaseTag ( releaseUnstableTag ) ) ;
155+ this . UpdateVersion ( projectDirectory , repository , versionOptions . Version , releaseVersion ) ;
156+ this . stdout . WriteLine ( $ "{ releaseBranchName } branch now tracks v{ releaseVersion } stabilization and release.") ;
162157
163158 // update version on main branch
164- this . stdout . WriteLine ( $ "Updating version on branch '{ originalBranchName } '...") ;
165159 Commands . Checkout ( repository , originalBranchName ) ;
166- this . UpdateVersion ( projectDirectory , repository ,
167- version =>
168- nextVersion ??
169- version
160+ var nextDevVersion = nextVersion ??
161+ versionOptions . Version
170162 . Increment ( releaseOptions . VersionIncrementOrDefault )
171- . SetFirstPrereleaseTag ( releaseOptions . FirstUnstableTagOrDefault ) ) ;
163+ . SetFirstPrereleaseTag ( releaseOptions . FirstUnstableTagOrDefault ) ;
164+ this . UpdateVersion ( projectDirectory , repository , versionOptions . Version , nextDevVersion ) ;
165+ this . stdout . WriteLine ( $ "{ originalBranchName } branch now tracks v{ nextDevVersion } development.") ;
172166
173167 // Merge release branch back to main branch
174- this . stdout . WriteLine ( $ "Merging branch '{ releaseBranchName } ' into '{ originalBranchName } '...") ;
175168 var mergeOptions = new MergeOptions ( )
176169 {
177170 CommitOnSuccess = true ,
@@ -197,32 +190,22 @@ private string GetReleaseBranchName(VersionOptions versionOptions)
197190 return branchNameFormat . Replace ( "{version}" , versionOptions . Version . Version . ToString ( ) ) ;
198191 }
199192
200- private void UpdateVersion ( string projectDirectory , Repository repository , Func < SemanticVersion , SemanticVersion > updateAction )
193+ private void UpdateVersion ( string projectDirectory , Repository repository , SemanticVersion oldVersion , SemanticVersion newVersion )
201194 {
202195 Requires . NotNull ( projectDirectory , nameof ( projectDirectory ) ) ;
203196 Requires . NotNull ( repository , nameof ( repository ) ) ;
204- Requires . NotNull ( updateAction , nameof ( updateAction ) ) ;
205197
206198 var signature = this . GetSignature ( repository ) ;
207-
208- var versionOptions = VersionFile . GetVersion ( projectDirectory ) ;
209- var oldVersion = versionOptions . Version ;
210- var newVersion = updateAction ( oldVersion ) ;
199+ var versionOptions = VersionFile . GetVersion ( repository , projectDirectory ) ;
211200
212201 if ( IsVersionDecrement ( oldVersion , newVersion ) )
213202 {
214203 this . stderr . WriteLine ( $ "Cannot change version from { oldVersion } to { newVersion } because { newVersion } is older than { oldVersion } .") ;
215204 throw new ReleasePreparationException ( ReleasePreparationError . VersionDecrement ) ;
216205 }
217206
218- if ( EqualityComparer < SemanticVersion > . Default . Equals ( versionOptions . Version , newVersion ) )
219- {
220- this . stdout . WriteLine ( $ "Version already set to { newVersion } .") ;
221- }
222- else
207+ if ( ! EqualityComparer < SemanticVersion > . Default . Equals ( versionOptions . Version , newVersion ) )
223208 {
224- this . stdout . WriteLine ( $ "Setting version to { newVersion } ...") ;
225-
226209 versionOptions . Version = newVersion ;
227210 var filePath = VersionFile . SetVersion ( projectDirectory , versionOptions , includeSchemaProperty : true ) ;
228211
0 commit comments