Current logic breaks when a branch name happens to contain "refs/heads/" in the middle.
Suppose a user (well, I mean myself) has $sourceBranch = "my/branch/contains/refs/heads/for/some/reason"
After
if (!$sourceBranch.Contains("refs")) {
$sourceBranch = "refs/heads/$sourceBranch"
}
no refs/heads/ is added at beginning since $sourceBranch.Contains("refs") is True, so $sourceBranch is still "my/branch/contains/refs/heads/for/some/reason"
Then after
# Remove the refs/heads/ or merge/pull from branches name (see issue #85)
if($sourceBranch.Contains("heads"))
{
$sourceBranch = $sourceBranch.Remove(0, 11)
}
elseif($sourceBranch.Contains("refs/pull"))
{
$sourceBranch = $sourceBranch.Remove(0, 10)
}
$sourceBranche becomes "ontains/refs/heads/for/some/reason" because first 10 chars are removed in the if($sourceBranch.Contains("heads")) block.
Eventually we'll find "Branch 'ontains/refs/heads/for/some/reason' not found in repository"
This PR makes sure to check refs/ prefix only at beginning of branch name.
Current logic breaks when a branch name happens to contain "refs/heads/" in the middle. Suppose a user (well, I mean myself) has
$sourceBranch = "my/branch/contains/refs/heads/for/some/reason"
Afterno
refs/heads/
is added at beginning since$sourceBranch.Contains("refs")
is True, so$sourceBranch
is still"my/branch/contains/refs/heads/for/some/reason"
Then after
$sourceBranche
becomes"ontains/refs/heads/for/some/reason"
because first 10 chars are removed in theif($sourceBranch.Contains("heads"))
block.Eventually we'll find "Branch 'ontains/refs/heads/for/some/reason' not found in repository"
This PR makes sure to check
refs/
prefix only at beginning of branch name.