Skip to content

Commit 676e792

Browse files
Refactor check for branch to reduce possible regression
1 parent 62c5aad commit 676e792

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

scm/driver/bitbucket/linker.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@ func (l *linker) Resource(ctx context.Context, repo string, ref scm.Reference) (
2525
case scm.IsPullRequest(ref.Path):
2626
d := scm.ExtractPullRequest(ref.Path)
2727
return fmt.Sprintf("%s%s/pull-requests/%d", l.base, repo, d), nil
28-
case scm.IsBranch(ref.Path) && ref.Sha == "":
28+
case ref.Sha == "":
2929
t := scm.TrimRef(ref.Path)
3030

3131
// Bitbucket has a bug where the "source view" link for
3232
// a branch which contains a slash results in a 404.
3333
// The link to the "branch view" works with names containing
3434
// a slash so we do this for branches with slashes in its names.
3535
// See https://jira.atlassian.com/browse/BCLOUD-14422 for more information
36-
//
37-
if strings.Contains(t, "/") {
36+
if scm.IsBranch(ref.Path) && strings.Contains(t, "/") {
3837
return fmt.Sprintf("%s%s/branch/%s", l.base, repo, t), nil
3938
}
4039

0 commit comments

Comments
 (0)