Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Commit

Permalink
repository/GetForEachRef: don't err, skip `bad´ lines instead
Browse files Browse the repository at this point in the history
  • Loading branch information
scorphus committed Sep 16, 2015
1 parent 4591617 commit e2333cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,8 @@ func (*GitContentRetriever) GetForEachRef(repo, pattern string) ([]Ref, error) {
authorDate = fields[7]
subject = strings.Join(fields[8:], "\t") // let there be subjects with \t
} else {
return nil, fmt.Errorf("Error when trying to obtain the refs of repository %s (Invalid git for-each-ref output [%s]).", repo, out)
log.Errorf("Could not match required ref elements for %s (invalid git input: %s).", repo, line)
continue
}
object := Ref{}
object.Ref = ref
Expand All @@ -552,7 +553,7 @@ func (*GitContentRetriever) GetForEachRef(repo, pattern string) ([]Ref, error) {
objects[objectCount] = object
objectCount++
}
return objects, nil
return objects[0:objectCount], nil
}

func (*GitContentRetriever) GetBranches(repo string) ([]Ref, error) {
Expand Down
5 changes: 3 additions & 2 deletions repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1373,8 +1373,9 @@ func (s *S) TestGetForEachRefOutputInvalid(c *check.C) {
tmpdir, err := commandmocker.Add("git", "-")
c.Assert(err, check.IsNil)
defer commandmocker.Remove(tmpdir)
_, err = GetForEachRef(repo, "")
c.Assert(err.Error(), check.Equals, "Error when trying to obtain the refs of repository gandalf-test-repo (Invalid git for-each-ref output [-]).")
refs, err := GetForEachRef(repo, "")
c.Assert(err, check.IsNil)
c.Assert(refs, check.HasLen, 0)
}

func (s *S) TestGetForEachRefOutputEmpty(c *check.C) {
Expand Down

0 comments on commit e2333cc

Please sign in to comment.