Instantly share code, notes, and snippets.

Embed
What would you like to do?
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