diff --git a/info_branch.go b/info_branch.go index 52a0cb8..19efc58 100644 --- a/info_branch.go +++ b/info_branch.go @@ -113,6 +113,7 @@ func (bs *BranchInfos) Parse() *BranchInfos { info, err := ParseBranchLine(line, verbose) if err != nil { bs.err = err + continue } // collect diff --git a/info_test.go b/info_test.go index e5ecc56..bbff267 100644 --- a/info_test.go +++ b/info_test.go @@ -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