Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix git init issue #37

Merged
merged 2 commits into from
Apr 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commands/status/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions commands/status/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ var testCasesExtractBranch = []struct {
[]byte("## Initial commit on master"),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure when this message gets printed. Is this for an older version of git? Maybe we should put a comment to describe how to replicate it in a real system.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if perhaps this is in fact the same message and it just changed text in more recent versions of git. Perhaps a search through the git codebase could tell us that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, looks like it was changed in git/git@4ddb135

&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},
Expand Down