From 9e6a03b7956464ccd9d2fbacedd8e5cc23572d02 Mon Sep 17 00:00:00 2001 From: Joshua Sjoding Date: Thu, 3 Mar 2016 00:33:00 -0800 Subject: Added Object interface for Commit, Tree, Blob and Tag * New Object interface is distinct from core.Object * New Object interface is used in places where returned object could be of any type * Object is implemented by Commit, Tree, Blob, File and Tag * Added Repository.Object function for retrieving objects of any type * Tag.Object now returns Object instead of core.Object * Tag target hash is now publicly accessible * Renamed Tag.Type field to Tag.TargetType, making it distinct from Tag.Type function * Fixed infinite recursive loop in TagIter.Close * TreeWalker.Next now returns Object instead of core.Object * Removed some duplicate test setup code --- commit_test.go | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'commit_test.go') diff --git a/commit_test.go b/commit_test.go index 62af890..a620e8c 100644 --- a/commit_test.go +++ b/commit_test.go @@ -2,10 +2,8 @@ package git import ( "io" - "os" "gopkg.in/src-d/go-git.v3/core" - "gopkg.in/src-d/go-git.v3/formats/packfile" . "gopkg.in/check.v1" ) @@ -18,27 +16,10 @@ var _ = Suite(&SuiteCommit{}) // create the repositories of the fixtures func (s *SuiteCommit) SetUpSuite(c *C) { - fixtureRepos := [...]struct { - url string - packfile string - }{ + commitFixtures := []packedFixture{ {"https://github.com/tyba/git-fixture.git", "formats/packfile/fixtures/git-fixture.ofs-delta"}, } - s.repos = make(map[string]*Repository, 0) - for _, fixRepo := range fixtureRepos { - s.repos[fixRepo.url] = NewPlainRepository() - - d, err := os.Open(fixRepo.packfile) - c.Assert(err, IsNil) - - r := packfile.NewReader(d) - r.Format = packfile.OFSDeltaFormat // TODO: how to know the format of a pack file ahead of time? - - _, err = r.Read(s.repos[fixRepo.url].Storage) - c.Assert(err, IsNil) - - c.Assert(d.Close(), IsNil) - } + s.repos = unpackFixtures(c, commitFixtures) } var commitIterTests = []struct { -- cgit