File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -294,9 +294,5 @@ func firstLine(output []byte) string {
294294
295295func getBranchShortName (output []byte ) string {
296296 branch := firstLine (output )
297- prefix := "refs/heads/"
298- if i := strings .Index (branch , prefix ); i != - 1 {
299- return branch [i + len (prefix ):]
300- }
301- return branch
297+ return strings .TrimPrefix (branch , "refs/heads/" )
302298}
Original file line number Diff line number Diff line change @@ -45,13 +45,17 @@ func Test_CurrentBranch(t *testing.T) {
4545 }
4646 cases := []c {
4747 {
48- Stub : "branch-name" ,
48+ Stub : "branch-name\n " ,
4949 Expected : "branch-name" ,
5050 },
5151 {
52- Stub : "refs/heads/branch-name" ,
52+ Stub : "refs/heads/branch-name\n " ,
5353 Expected : "branch-name" ,
5454 },
55+ {
56+ Stub : "refs/heads/branch\u00A0 with\u00A0 non\u00A0 breaking\u00A0 space\n " ,
57+ Expected : "branch\u00A0 with\u00A0 non\u00A0 breaking\u00A0 space" ,
58+ },
5559 }
5660
5761 for _ , v := range cases {
You can’t perform that action at this time.
0 commit comments