Skip to content

Commit

Permalink
fix: fix not add continue on parse branch line error
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jun 29, 2022
1 parent 011dc24 commit 77e6932
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions info_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (bs *BranchInfos) Parse() *BranchInfos {
info, err := ParseBranchLine(line, verbose)
if err != nil {
bs.err = err
continue
}

// collect
Expand Down
17 changes: 17 additions & 0 deletions info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ func TestBranchInfo_parse_simple(t *testing.T) {
assert.Equal(t, "master", bis.Current().Name)
}

func TestBranchInfo_parse_invalid(t *testing.T) {
gitOut := `
fea/new_br001
* (HEAD)
my_new_br
remotes/origin/my_new_br
`
bis := gitw.NewBranchInfos(gitOut)
bis.Parse()
// dump.P(bis)

assert.Error(t, bis.LastErr())
assert.Nil(t, bis.Current())
assert.NotEmpty(t, bis.Locales())
assert.NotEmpty(t, bis.Remotes("origin"))
}

func TestBranchInfo_parse_verbose(t *testing.T) {
gitOut := `
fea/new_br001 73j824d the message 001
Expand Down

0 comments on commit 77e6932

Please sign in to comment.