Skip to content

Instantly share code, notes, and snippets.

@lydemann
Last active November 3, 2018 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lydemann/b6928730f5a548ac46f686bdb43753b4 to your computer and use it in GitHub Desktop.
Save lydemann/b6928730f5a548ac46f686bdb43753b4 to your computer and use it in GitHub Desktop.
get-branch-without-prefix
param(
[string]$branch = "master"
)
$prefix, $name = $branch.Split("/");
Write-Host "Found prefix: $prefix, and name: $name";
if ([string]::IsNullOrEmpty($prefix) -and [string]::IsNullOrEmpty($name)) {
exit(-1);
}
if (-not [string]::IsNullOrEmpty($name)) {
Write-Output $name
exit(0);
}
if (-not [string]::IsNullOrEmpty($prefix)) {
Write-Output $prefix
exit(0);
}
exit(-1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment