diff --git a/commands/status/process.go b/commands/status/process.go index e75ce8a..d98d675 100644 --- a/commands/status/process.go +++ b/commands/status/process.go @@ -67,7 +67,7 @@ func ExtractBranch(bs []byte) *BranchInfo { } func decodeBranchName(bs []byte) (branch string) { - branchRegex := regexp.MustCompile(`^## (?:Initial commit on )?(\S+?)(?:\.{3}|$)`) + branchRegex := regexp.MustCompile(`^## (?:Initial commit on )?(?:No commits yet on )?(\S+?)(?:\.{3}|$)`) headRegex := regexp.MustCompile(`^## (HEAD \(no branch\))`) branchMatch := branchRegex.FindSubmatch(bs) diff --git a/commands/status/process_test.go b/commands/status/process_test.go index 94d1556..012f481 100644 --- a/commands/status/process_test.go +++ b/commands/status/process_test.go @@ -238,6 +238,10 @@ var testCasesExtractBranch = []struct { []byte("## Initial commit on master"), &BranchInfo{name: "master", ahead: 0, behind: 0}, }, + { + []byte("## No commits yet on master"), + &BranchInfo{name: "master", ahead: 0, behind: 0}, + }, { []byte("## 3.0...origin/3.0 [ahead 1]"), &BranchInfo{name: "3.0", ahead: 1, behind: 0},