Skip to content

Commit cf1a99a

Browse files
committed
fix current branch
1 parent 6d54258 commit cf1a99a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

git/git.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/ioutil"
66
"os"
77
"os/exec"
8+
"strings"
89
)
910

1011
// TODO: Fetch target not master
@@ -21,14 +22,14 @@ func Fetch() error {
2122

2223
func CurrentBranch() (string, error) {
2324
out, err := exec.Command(
24-
"git", "branch", "--show-current",
25+
"git", "rev-parse", "--abbrev-ref", "HEAD",
2526
).CombinedOutput()
2627
if err != nil {
2728
fmt.Println(string(out))
2829
return "", fmt.Errorf("error getting current branch: %v\n%v", string(out), err)
2930
}
3031

31-
return string(out), nil
32+
return strings.TrimSpace(string(out)), nil
3233
}
3334

3435
func Diff(targetBranch string) (string, error) {

0 commit comments

Comments
 (0)