Skip to content

Instantly share code, notes, and snippets.

@MrJerB
Last active January 11, 2022 14:19
Show Gist options
  • Save MrJerB/e4ed4ddcdb86ff51e894bf3da549de7f to your computer and use it in GitHub Desktop.
Save MrJerB/e4ed4ddcdb86ff51e894bf3da549de7f to your computer and use it in GitHub Desktop.
Create release branch on origin with same name as currently checked out feature branch.
function Publish-RemoteReleaseBranch {
param ([string] $Suffix = $null, [switch] $Copy = $false, [switch] $SetGlobal = $false)
$currentBranch = git branch --show-current;
if (!$currentBranch.StartsWith("feature/")) {
Write-Host "Not a feature branch";
return;
}
if ($Suffix -and !$Suffix.StartsWith("_")) {
$Suffix = "_$Suffix"
}
$releaseBranchName = "release$($currentBranch.Substring(7))$Suffix";
git push origin origin/master:refs/heads/$releaseBranchName;
if ($Copy) {
$releaseBranchName | Set-Clipboard;
}
if ($SetGlobal) {
$Global:ReleaseBranchName = $releaseBranchName;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment