diff --git a/repository/repository.go b/repository/repository.go index f3a006d..785c2df 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -369,6 +369,9 @@ func (*GitContentRetriever) GetForEachRef(repo, pattern string) ([]map[string]st return nil, fmt.Errorf("Error when trying to obtain the refs of repository %s (%s).", repo, err) } lines := strings.Split(strings.TrimSpace(string(out)), "\n") + if len(lines) == 1 && len(lines[0]) == 0 { + return nil, nil + } objectCount := len(lines) objects := make([]map[string]string, objectCount) objectCount = 0 diff --git a/repository/repository_test.go b/repository/repository_test.go index 74d2ffa..4666203 100644 --- a/repository/repository_test.go +++ b/repository/repository_test.go @@ -909,3 +909,20 @@ func (s *S) TestGetForEachRefIntegrationSubjectWithTab(c *gocheck.C) { c.Assert(refs[1]["authorEmail"], gocheck.Equals, "") c.Assert(refs[1]["subject"], gocheck.Equals, "will\tbark") } + +func (s *S) TestGetForEachRefIntegrationWhenNoPatternSupplied(c *gocheck.C) { + oldBare := bare + bare = "/tmp" + repo := "gandalf-test-repo" + file := "README" + content := "much WOW" + cleanUp, errCreate := CreateTestRepository(bare, repo, file, content) + defer func() { + cleanUp() + bare = oldBare + }() + c.Assert(errCreate, gocheck.IsNil) + refs, err := GetForEachRef("gandalf-test-repo", "") + c.Assert(refs, gocheck.IsNil) + c.Assert(err, gocheck.IsNil) +}