Skip to content

Commit

Permalink
Returns branch name as main if ref as refs-heads-main
Browse files Browse the repository at this point in the history
Signed-off-by: Shivam Mukhade <[email protected]>
  • Loading branch information
Shivam Mukhade committed Dec 10, 2021
1 parent 69e49b6 commit 4c50da8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
3 changes: 3 additions & 0 deletions pkg/formatting/vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ func SanitizeBranch(s string) string {
if strings.HasPrefix(s, "refs/heads/") {
return strings.TrimPrefix(s, "refs/heads/")
}
if s == "refs-heads-main" {
return "main"
}
return s
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/formatting/vcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func TestSanitizeBranch(t *testing.T) {
args: args{s: "refs/tags/1.0"},
want: "refs/tags/1.0",
},
{
name: "sanitize main ref",
args: args{s: "refs-heads-main"},
want: "main",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
44 changes: 22 additions & 22 deletions vendor/github.com/AlecAivazis/survey/v2/terminal/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4c50da8

Please sign in to comment.