From 922f4ed5a42123af0e4b74030273429f9fbaa43a Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Wed, 15 Aug 2018 09:42:02 +1000 Subject: try rev-parse of git symbolic-ref returns nothing --- pkg/git/branch_list_builder.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/git/branch_list_builder.go b/pkg/git/branch_list_builder.go index 41e59c093..e4a8461b8 100644 --- a/pkg/git/branch_list_builder.go +++ b/pkg/git/branch_list_builder.go @@ -39,7 +39,10 @@ func (b *BranchListBuilder) obtainCurrentBranch() commands.Branch { // even though you're on 'master' branchName, err := b.GitCommand.OSCommand.RunCommandWithOutput("git symbolic-ref --short HEAD") if err != nil { - panic(err.Error()) + branchName, err = b.GitCommand.OSCommand.RunCommandWithOutput("git rev-parse --short HEAD") + if err != nil { + panic(err.Error()) + } } return commands.Branch{Name: strings.TrimSpace(branchName), Recency: " *"} } -- cgit v1.2.3 From 0687c07f50d7af4dce51f76a8f1eb38eb7ee1d1a Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Wed, 15 Aug 2018 09:45:24 +1000 Subject: more robust reading of reflog to get branch name --- pkg/git/branch_list_builder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/git/branch_list_builder.go b/pkg/git/branch_list_builder.go index e4a8461b8..869e05c98 100644 --- a/pkg/git/branch_list_builder.go +++ b/pkg/git/branch_list_builder.go @@ -144,7 +144,7 @@ func branchInfoFromLine(line string) (string, string, string) { r := regexp.MustCompile("\\|.*\\s") line = r.ReplaceAllString(line, " ") words := strings.Split(line, " ") - return words[0], words[1], words[3] + return words[0], words[1], words[len(words)-1] } func abbreviatedTimeUnit(timeUnit string) string { -- cgit v1.2.3