Skip to content

Commit 490d990

Browse files
committed
Checkout branch in Update-Version too
1 parent b23beda commit 490d990

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

tools/ReleaseTools.psm1

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ function Get-FirstChangelog {
134134
)
135135
}
136136

137+
<#
138+
.SYNOPSIS
139+
Creates and checks out `release/v<version>` if not already on it.
140+
#>
141+
function Update-Branch {
142+
param(
143+
[Parameter(Mandatory)]
144+
[string]$Version
145+
)
146+
$branch = git branch --show-current
147+
if ($branch -ne "release/v$Version") {
148+
git checkout -b "release/v$Version"
149+
}
150+
}
151+
137152
<#
138153
.SYNOPSIS
139154
Gets current version from changelog as [semver].
@@ -221,10 +236,7 @@ function Update-Changelog {
221236
) | Set-Content -Encoding utf8NoBOM -Path $ChangelogFile
222237

223238
if ($PSCmdlet.ShouldProcess("$RepositoryName/$ChangelogFile", "git")) {
224-
$branch = git branch --show-current
225-
if ($branch -ne "release/$Version") {
226-
git checkout -b "release/$Version"
227-
}
239+
Update-Branch -Version $Version
228240
git add $ChangelogFile
229241
git commit -m "Update CHANGELOG for $Version"
230242
}
@@ -311,6 +323,7 @@ function Update-Version {
311323
}
312324

313325
if ($PSCmdlet.ShouldProcess("$RepositoryName/v$Version", "git commit")) {
326+
Update-Branch -Version $Version
314327
git commit -m "Bump version to v$Version"
315328
}
316329

0 commit comments

Comments
 (0)