diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-11-08 23:46:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-08 23:46:38 +0100 |
commit | ac095bb12c4d29722b60ba9f20590fa7cfa6bc7d (patch) | |
tree | 223f36f336ba3414b1e45cac8af6c4744a5d7ef6 | |
parent | e523701393598f4fa241dd407af9ff8925507a1a (diff) | |
download | go-git-ac095bb12c4d29722b60ba9f20590fa7cfa6bc7d.tar.gz |
new plumbing package (#118)
* plumbing: now core was renamed to core, and formats and clients moved inside
-rw-r--r-- | blame.go | 6 | ||||
-rw-r--r-- | blame_test.go | 10 | ||||
-rw-r--r-- | blobs.go | 37 | ||||
-rw-r--r-- | blobs_test.go | 14 | ||||
-rw-r--r-- | commit.go | 45 | ||||
-rw-r--r-- | commit_test.go | 30 | ||||
-rw-r--r-- | commit_walker.go | 6 | ||||
-rw-r--r-- | common.go | 6 | ||||
-rw-r--r-- | common_test.go | 26 | ||||
-rw-r--r-- | config/refspec.go | 18 | ||||
-rw-r--r-- | config/refspec_test.go | 20 | ||||
-rw-r--r-- | core/object_test.go | 176 | ||||
-rw-r--r-- | core/storage.go | 83 | ||||
-rw-r--r-- | cshared/auth_method_cshared.go | 4 | ||||
-rw-r--r-- | cshared/commit_cshared.go | 7 | ||||
-rw-r--r-- | cshared/file_cshared.go | 4 | ||||
-rw-r--r-- | cshared/objects_cshared.go | 4 | ||||
-rw-r--r-- | cshared/repository_cshared.go | 12 | ||||
-rw-r--r-- | cshared/tag_cshared.go | 7 | ||||
-rw-r--r-- | cshared/tree_cshared.go | 4 | ||||
-rw-r--r-- | examples/remotes/main.go | 6 | ||||
-rw-r--r-- | examples/storage/aerospike/storage.go | 53 | ||||
-rw-r--r-- | file.go | 6 | ||||
-rw-r--r-- | file_test.go | 15 | ||||
-rw-r--r-- | fixtures/fixtures.go | 72 | ||||
-rw-r--r-- | formats/packfile/scanner_test.go | 189 | ||||
-rw-r--r-- | objects.go | 35 | ||||
-rw-r--r-- | objects_test.go | 6 | ||||
-rw-r--r-- | options.go | 12 | ||||
-rw-r--r-- | plumbing/client/common.go (renamed from clients/common.go) | 6 | ||||
-rw-r--r-- | plumbing/client/common/common.go (renamed from clients/common/common.go) | 43 | ||||
-rw-r--r-- | plumbing/client/common/common_test.go (renamed from clients/common/common_test.go) | 26 | ||||
-rw-r--r-- | plumbing/client/common_test.go (renamed from clients/common_test.go) | 2 | ||||
-rw-r--r-- | plumbing/client/http/common.go (renamed from clients/http/common.go) | 6 | ||||
-rw-r--r-- | plumbing/client/http/common_test.go (renamed from clients/http/common_test.go) | 0 | ||||
-rw-r--r-- | plumbing/client/http/git_upload_pack.go (renamed from clients/http/git_upload_pack.go) | 10 | ||||
-rw-r--r-- | plumbing/client/http/git_upload_pack_test.go (renamed from clients/http/git_upload_pack_test.go) | 14 | ||||
-rw-r--r-- | plumbing/client/ssh/auth_method.go (renamed from clients/ssh/auth_method.go) | 2 | ||||
-rw-r--r-- | plumbing/client/ssh/auth_method_test.go (renamed from clients/ssh/auth_method_test.go) | 0 | ||||
-rw-r--r-- | plumbing/client/ssh/git_upload_pack.go (renamed from clients/ssh/git_upload_pack.go) | 8 | ||||
-rw-r--r-- | plumbing/client/ssh/git_upload_pack_test.go (renamed from clients/ssh/git_upload_pack_test.go) | 12 | ||||
-rw-r--r-- | plumbing/errors.go (renamed from core/errors.go) | 2 | ||||
-rw-r--r-- | plumbing/format/config/common.go (renamed from formats/config/common.go) | 0 | ||||
-rw-r--r-- | plumbing/format/config/common_test.go (renamed from formats/config/common_test.go) | 0 | ||||
-rw-r--r-- | plumbing/format/config/decoder.go (renamed from formats/config/decoder.go) | 0 | ||||
-rw-r--r-- | plumbing/format/config/decoder_test.go (renamed from formats/config/decoder_test.go) | 0 | ||||
-rw-r--r-- | plumbing/format/config/doc.go (renamed from formats/config/doc.go) | 0 | ||||
-rw-r--r-- | plumbing/format/config/encoder.go (renamed from formats/config/encoder.go) | 0 | ||||
-rw-r--r-- | plumbing/format/config/encoder_test.go (renamed from formats/config/encoder_test.go) | 0 | ||||
-rw-r--r-- | plumbing/format/config/fixtures_test.go (renamed from formats/config/fixtures_test.go) | 0 | ||||
-rw-r--r-- | plumbing/format/config/option.go (renamed from formats/config/option.go) | 0 | ||||
-rw-r--r-- | plumbing/format/config/option_test.go (renamed from formats/config/option_test.go) | 0 | ||||
-rw-r--r-- | plumbing/format/config/section.go (renamed from formats/config/section.go) | 0 | ||||
-rw-r--r-- | plumbing/format/config/section_test.go (renamed from formats/config/section_test.go) | 0 | ||||
-rw-r--r-- | plumbing/format/idxfile/decoder.go (renamed from formats/idxfile/decoder.go) | 4 | ||||
-rw-r--r-- | plumbing/format/idxfile/decoder_test.go (renamed from formats/idxfile/decoder_test.go) | 2 | ||||
-rw-r--r-- | plumbing/format/idxfile/doc.go (renamed from formats/idxfile/doc.go) | 0 | ||||
-rw-r--r-- | plumbing/format/idxfile/encoder.go (renamed from formats/idxfile/encoder.go) | 0 | ||||
-rw-r--r-- | plumbing/format/idxfile/encoder_test.go (renamed from formats/idxfile/encoder_test.go) | 6 | ||||
-rw-r--r-- | plumbing/format/idxfile/idxfile.go (renamed from formats/idxfile/idxfile.go) | 6 | ||||
-rw-r--r-- | plumbing/format/index/decoder.go (renamed from formats/index/decoder.go) | 10 | ||||
-rw-r--r-- | plumbing/format/index/decoder_test.go (renamed from formats/index/decoder_test.go) | 22 | ||||
-rw-r--r-- | plumbing/format/index/doc.go (renamed from formats/index/doc.go) | 4 | ||||
-rw-r--r-- | plumbing/format/index/encoder.go (renamed from formats/index/encoder.go) | 0 | ||||
-rw-r--r-- | plumbing/format/index/encoder_test.go (renamed from formats/index/encoder_test.go) | 4 | ||||
-rw-r--r-- | plumbing/format/index/index.go (renamed from formats/index/index.go) | 8 | ||||
-rw-r--r-- | plumbing/format/objfile/common_test.go (renamed from formats/objfile/common_test.go) | 26 | ||||
-rw-r--r-- | plumbing/format/objfile/reader.go (renamed from formats/objfile/reader.go) | 16 | ||||
-rw-r--r-- | plumbing/format/objfile/reader_test.go (renamed from formats/objfile/reader_test.go) | 6 | ||||
-rw-r--r-- | plumbing/format/objfile/writer.go (renamed from formats/objfile/writer.go) | 16 | ||||
-rw-r--r-- | plumbing/format/objfile/writer_test.go (renamed from formats/objfile/writer_test.go) | 16 | ||||
-rw-r--r-- | plumbing/format/packfile/decoder.go (renamed from formats/packfile/decoder.go) | 75 | ||||
-rw-r--r-- | plumbing/format/packfile/decoder_test.go (renamed from formats/packfile/decoder_test.go) | 14 | ||||
-rw-r--r-- | plumbing/format/packfile/delta.go (renamed from formats/packfile/delta.go) | 4 | ||||
-rw-r--r-- | plumbing/format/packfile/doc.go (renamed from formats/packfile/doc.go) | 0 | ||||
-rw-r--r-- | plumbing/format/packfile/error.go (renamed from formats/packfile/error.go) | 0 | ||||
-rw-r--r-- | plumbing/format/packfile/scanner.go (renamed from formats/packfile/scanner.go) | 24 | ||||
-rw-r--r-- | plumbing/format/packfile/scanner_test.go | 189 | ||||
-rw-r--r-- | plumbing/format/packp/advrefs/advrefs.go (renamed from formats/packp/advrefs/advrefs.go) | 18 | ||||
-rw-r--r-- | plumbing/format/packp/advrefs/advrefs_test.go (renamed from formats/packp/advrefs/advrefs_test.go) | 16 | ||||
-rw-r--r-- | plumbing/format/packp/advrefs/decoder.go (renamed from formats/packp/advrefs/decoder.go) | 16 | ||||
-rw-r--r-- | plumbing/format/packp/advrefs/decoder_test.go (renamed from formats/packp/advrefs/decoder_test.go) | 88 | ||||
-rw-r--r-- | plumbing/format/packp/advrefs/encoder.go (renamed from formats/packp/advrefs/encoder.go) | 16 | ||||
-rw-r--r-- | plumbing/format/packp/advrefs/encoder_test.go (renamed from formats/packp/advrefs/encoder_test.go) | 86 | ||||
-rw-r--r-- | plumbing/format/packp/capabilities.go (renamed from formats/packp/capabilities.go) | 0 | ||||
-rw-r--r-- | plumbing/format/packp/capabilities_test.go (renamed from formats/packp/capabilities_test.go) | 0 | ||||
-rw-r--r-- | plumbing/format/packp/doc.go (renamed from formats/packp/doc.go) | 0 | ||||
-rw-r--r-- | plumbing/format/packp/pktline/encoder.go (renamed from formats/packp/pktline/encoder.go) | 0 | ||||
-rw-r--r-- | plumbing/format/packp/pktline/encoder_test.go (renamed from formats/packp/pktline/encoder_test.go) | 2 | ||||
-rw-r--r-- | plumbing/format/packp/pktline/scanner.go (renamed from formats/packp/pktline/scanner.go) | 0 | ||||
-rw-r--r-- | plumbing/format/packp/pktline/scanner_test.go (renamed from formats/packp/pktline/scanner_test.go) | 2 | ||||
-rw-r--r-- | plumbing/format/packp/ulreq/decoder.go (renamed from formats/packp/ulreq/decoder.go) | 12 | ||||
-rw-r--r-- | plumbing/format/packp/ulreq/decoder_test.go (renamed from formats/packp/ulreq/decoder_test.go) | 110 | ||||
-rw-r--r-- | plumbing/format/packp/ulreq/encoder.go (renamed from formats/packp/ulreq/encoder.go) | 6 | ||||
-rw-r--r-- | plumbing/format/packp/ulreq/encoder_test.go (renamed from formats/packp/ulreq/encoder_test.go) | 68 | ||||
-rw-r--r-- | plumbing/format/packp/ulreq/ulreq.go (renamed from formats/packp/ulreq/ulreq.go) | 12 | ||||
-rw-r--r-- | plumbing/format/packp/ulreq/ulreq_test.go (renamed from formats/packp/ulreq/ulreq_test.go) | 14 | ||||
-rw-r--r-- | plumbing/hash.go (renamed from core/hash.go) | 2 | ||||
-rw-r--r-- | plumbing/hash_test.go (renamed from core/hash_test.go) | 2 | ||||
-rw-r--r-- | plumbing/memory.go (renamed from core/memory.go) | 2 | ||||
-rw-r--r-- | plumbing/memory_test.go (renamed from core/memory_test.go) | 2 | ||||
-rw-r--r-- | plumbing/object.go | 94 | ||||
-rw-r--r-- | plumbing/object_test.go | 46 | ||||
-rw-r--r-- | plumbing/reference.go (renamed from core/reference.go) | 88 | ||||
-rw-r--r-- | plumbing/reference_test.go (renamed from core/reference_test.go) | 63 | ||||
-rw-r--r-- | plumbing/storer/index.go | 9 | ||||
-rw-r--r-- | plumbing/storer/object.go (renamed from core/object.go) | 172 | ||||
-rw-r--r-- | plumbing/storer/object_test.go | 150 | ||||
-rw-r--r-- | plumbing/storer/reference.go | 109 | ||||
-rw-r--r-- | plumbing/storer/reference_test.go | 67 | ||||
-rw-r--r-- | references.go | 10 | ||||
-rw-r--r-- | references_test.go | 8 | ||||
-rw-r--r-- | remote.go | 51 | ||||
-rw-r--r-- | remote_test.go | 29 | ||||
-rw-r--r-- | repository.go | 63 | ||||
-rw-r--r-- | repository_test.go | 70 | ||||
-rw-r--r-- | storage/filesystem/config.go | 2 | ||||
-rw-r--r-- | storage/filesystem/internal/dotgit/dotgit.go | 50 | ||||
-rw-r--r-- | storage/filesystem/internal/dotgit/dotgit_test.go | 26 | ||||
-rw-r--r-- | storage/filesystem/internal/dotgit/writers.go | 12 | ||||
-rw-r--r-- | storage/filesystem/object.go | 97 | ||||
-rw-r--r-- | storage/filesystem/object_test.go | 24 | ||||
-rw-r--r-- | storage/filesystem/reference.go | 11 | ||||
-rw-r--r-- | storage/memory/storage.go | 93 | ||||
-rw-r--r-- | storage/test/storage_suite.go | 113 | ||||
-rw-r--r-- | tag.go | 49 | ||||
-rw-r--r-- | tag_test.go | 46 | ||||
-rw-r--r-- | tree.go | 43 | ||||
-rw-r--r-- | tree_diff.go | 6 | ||||
-rw-r--r-- | tree_diff_test.go | 18 | ||||
-rw-r--r-- | tree_test.go | 330 | ||||
-rw-r--r-- | utils/binary/read.go | 10 | ||||
-rw-r--r-- | utils/binary/read_test.go | 4 |
133 files changed, 2000 insertions, 1933 deletions
@@ -8,13 +8,13 @@ import ( "strings" "unicode/utf8" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/diff" + "gopkg.in/src-d/go-git.v4/plumbing" ) type Blame struct { Path string - Rev core.Hash + Rev plumbing.Hash Lines []*line } @@ -256,7 +256,7 @@ func prettyPrintAuthor(c *Commit) string { // utility function to calculate the number of runes needed // to print the longest author name in the blame of a file. func (b *blame) maxAuthorLength() int { - memo := make(map[core.Hash]struct{}, len(b.graph)-1) + memo := make(map[plumbing.Hash]struct{}, len(b.graph)-1) fVs := b.graph[len(b.graph)-1] m := 0 for ln := range fVs { diff --git a/blame_test.go b/blame_test.go index 2d9161c..53f2271 100644 --- a/blame_test.go +++ b/blame_test.go @@ -1,8 +1,8 @@ package git import ( - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" + "gopkg.in/src-d/go-git.v4/plumbing" . "gopkg.in/check.v1" ) @@ -24,7 +24,7 @@ func (s *BlameSuite) mockBlame(t blameTest, c *C) (blame *Blame) { r, ok := s.Repositories[t.repo] c.Assert(ok, Equals, true) - commit, err := r.Commit(core.NewHash(t.rev)) + commit, err := r.Commit(plumbing.NewHash(t.rev)) c.Assert(err, IsNil, Commentf("%v: repo=%s, rev=%s", err, r, t.rev)) f, err := commit.File(t.path) @@ -36,7 +36,7 @@ func (s *BlameSuite) mockBlame(t blameTest, c *C) (blame *Blame) { blamedLines := make([]*line, 0, len(t.blames)) for i := range t.blames { - commit, err := r.Commit(core.NewHash(t.blames[i])) + commit, err := r.Commit(plumbing.NewHash(t.blames[i])) c.Assert(err, IsNil) l := &line{ author: commit.Author.Email, @@ -47,7 +47,7 @@ func (s *BlameSuite) mockBlame(t blameTest, c *C) (blame *Blame) { return &Blame{ Path: t.path, - Rev: core.NewHash(t.rev), + Rev: plumbing.NewHash(t.rev), Lines: blamedLines, } } @@ -65,7 +65,7 @@ func (s *BlameSuite) TestBlame(c *C) { r, ok := s.Repositories[t.repo] c.Assert(ok, Equals, true) - commit, err := r.Commit(core.NewHash(t.rev)) + commit, err := r.Commit(plumbing.NewHash(t.rev)) c.Assert(err, IsNil) obt, err := commit.Blame(t.path) @@ -3,35 +3,36 @@ package git import ( "io" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" ) // Blob is used to store file data - it is generally a file. type Blob struct { - Hash core.Hash + Hash plumbing.Hash Size int64 - obj core.Object + obj plumbing.Object } // ID returns the object ID of the blob. The returned value will always match // the current value of Blob.Hash. // // ID is present to fulfill the Object interface. -func (b *Blob) ID() core.Hash { +func (b *Blob) ID() plumbing.Hash { return b.Hash } -// Type returns the type of object. It always returns core.BlobObject. +// Type returns the type of object. It always returns plumbing.BlobObject. // // Type is present to fulfill the Object interface. -func (b *Blob) Type() core.ObjectType { - return core.BlobObject +func (b *Blob) Type() plumbing.ObjectType { + return plumbing.BlobObject } -// Decode transforms a core.Object into a Blob struct. -func (b *Blob) Decode(o core.Object) error { - if o.Type() != core.BlobObject { +// Decode transforms a plumbing.Object into a Blob struct. +func (b *Blob) Decode(o plumbing.Object) error { + if o.Type() != plumbing.BlobObject { return ErrUnsupportedObject } @@ -42,8 +43,8 @@ func (b *Blob) Decode(o core.Object) error { return nil } -// Encode transforms a Blob into a core.Object. -func (b *Blob) Encode(o core.Object) error { +// Encode transforms a Blob into a plumbing.Object. +func (b *Blob) Encode(o plumbing.Object) error { w, err := o.Writer() if err != nil { return err @@ -55,7 +56,7 @@ func (b *Blob) Encode(o core.Object) error { } defer checkClose(r, &err) _, err = io.Copy(w, r) - o.SetType(core.BlobObject) + o.SetType(plumbing.BlobObject) return err } @@ -66,7 +67,7 @@ func (b *Blob) Reader() (io.ReadCloser, error) { // BlobIter provides an iterator for a set of blobs. type BlobIter struct { - core.ObjectIter + storer.ObjectIter r *Repository } @@ -74,7 +75,7 @@ type BlobIter struct { // object iterator. // // The returned BlobIter will automatically skip over non-blob objects. -func NewBlobIter(r *Repository, iter core.ObjectIter) *BlobIter { +func NewBlobIter(r *Repository, iter storer.ObjectIter) *BlobIter { return &BlobIter{iter, r} } @@ -87,7 +88,7 @@ func (iter *BlobIter) Next() (*Blob, error) { return nil, err } - if obj.Type() != core.BlobObject { + if obj.Type() != plumbing.BlobObject { continue } @@ -100,8 +101,8 @@ func (iter *BlobIter) Next() (*Blob, error) { // an error happens or the end of the iter is reached. If ErrStop is sent // the iteration is stop but no error is returned. The iterator is closed. func (iter *BlobIter) ForEach(cb func(*Blob) error) error { - return iter.ObjectIter.ForEach(func(obj core.Object) error { - if obj.Type() != core.BlobObject { + return iter.ObjectIter.ForEach(func(obj plumbing.Object) error { + if obj.Type() != plumbing.BlobObject { return nil } diff --git a/blobs_test.go b/blobs_test.go index b667fa4..a323744 100644 --- a/blobs_test.go +++ b/blobs_test.go @@ -4,7 +4,7 @@ import ( "io" "io/ioutil" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" . "gopkg.in/check.v1" ) @@ -16,8 +16,8 @@ type BlobsSuite struct { var _ = Suite(&BlobsSuite{}) func (s *BlobsSuite) TestBlobHash(c *C) { - o := &core.MemoryObject{} - o.SetType(core.BlobObject) + o := &plumbing.MemoryObject{} + o.SetType(plumbing.BlobObject) o.SetSize(3) writer, err := o.Writer() @@ -42,11 +42,11 @@ func (s *BlobsSuite) TestBlobHash(c *C) { } func (s *BlobsSuite) TestBlobDecodeEncodeIdempotent(c *C) { - var objects []*core.MemoryObject + var objects []*plumbing.MemoryObject for _, str := range []string{"foo", "foo\n"} { - obj := &core.MemoryObject{} + obj := &plumbing.MemoryObject{} obj.Write([]byte(str)) - obj.SetType(core.BlobObject) + obj.SetType(plumbing.BlobObject) obj.Hash() objects = append(objects, obj) } @@ -54,7 +54,7 @@ func (s *BlobsSuite) TestBlobDecodeEncodeIdempotent(c *C) { blob := &Blob{} err := blob.Decode(object) c.Assert(err, IsNil) - newObject := &core.MemoryObject{} + newObject := &plumbing.MemoryObject{} err = blob.Encode(newObject) c.Assert(err, IsNil) newObject.Hash() // Ensure Hash is pre-computed before deep comparison @@ -8,11 +8,12 @@ import ( "sort" "strings" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" ) // Hash hash of an object -type Hash core.Hash +type Hash plumbing.Hash // Commit points to a single tree, marking it as what the project looked like // at a certain point in time. It contains meta-information about that point @@ -20,13 +21,13 @@ type Hash core.Hash // commit, a pointer to the previous commit(s), etc. // http://schacon.github.io/gitbook/1_the_git_object_model.html type Commit struct { - Hash core.Hash + Hash plumbing.Hash Author Signature Committer Signature Message string - tree core.Hash - parents []core.Hash + tree plumbing.Hash + parents []plumbing.Hash r *Repository } @@ -38,7 +39,7 @@ func (c *Commit) Tree() (*Tree, error) { // Parents return a CommitIter to the parent Commits func (c *Commit) Parents() *CommitIter { return NewCommitIter(c.r, - core.NewObjectLookupIter(c.r.s, core.CommitObject, c.parents), + storer.NewObjectLookupIter(c.r.s, plumbing.CommitObject, c.parents), ) } @@ -73,20 +74,20 @@ func (c *Commit) Files() (*FileIter, error) { // the current value of Commit.Hash. // // ID is present to fulfill the Object interface. -func (c *Commit) ID() core.Hash { +func (c *Commit) ID() plumbing.Hash { return c.Hash } -// Type returns the type of object. It always returns core.CommitObject. +// Type returns the type of object. It always returns plumbing.CommitObject. // // Type is present to fulfill the Object interface. -func (c *Commit) Type() core.ObjectType { - return core.CommitObject +func (c *Commit) Type() plumbing.ObjectType { + return plumbing.CommitObject } -// Decode transforms a core.Object into a Commit struct. -func (c *Commit) Decode(o core.Object) (err error) { - if o.Type() != core.CommitObject { +// Decode transforms a plumbing.Object into a Commit struct. +func (c *Commit) Decode(o plumbing.Object) (err error) { + if o.Type() != plumbing.CommitObject { return ErrUnsupportedObject } @@ -117,9 +118,9 @@ func (c *Commit) Decode(o core.Object) (err error) { split := bytes.SplitN(line, []byte{' '}, 2) switch string(split[0]) { case "tree": - c.tree = core.NewHash(string(split[1])) + c.tree = plumbing.NewHash(string(split[1])) case "parent": - c.parents = append(c.parents, core.NewHash(string(split[1]))) + c.parents = append(c.parents, plumbing.NewHash(string(split[1]))) case "author": c.Author.Decode(split[1]) case "committer": @@ -147,9 +148,9 @@ func (c *Commit) History() ([]*Commit, error) { return commits, err } -// Encode transforms a Commit into a core.Object. -func (b *Commit) Encode(o core.Object) error { - o.SetType(core.CommitObject) +// Encode transforms a Commit into a plumbing.Object. +func (b *Commit) Encode(o plumbing.Object) error { + o.SetType(plumbing.CommitObject) w, err := o.Writer() if err != nil { return err @@ -184,7 +185,7 @@ func (b *Commit) Encode(o core.Object) error { func (c *Commit) String() string { return fmt.Sprintf( "%s %s\nAuthor: %s\nDate: %s\n\n%s\n", - core.CommitObject, c.Hash, c.Author.String(), + plumbing.CommitObject, c.Hash, c.Author.String(), c.Author.When.Format(DateFormat), indent(c.Message), ) } @@ -204,7 +205,7 @@ func indent(t string) string { // CommitIter provides an iterator for a set of commits. type CommitIter struct { - core.ObjectIter + storer.ObjectIter r *Repository } @@ -212,7 +213,7 @@ type CommitIter struct { // object iterator. // // The returned CommitIter will automatically skip over non-commit objects. -func NewCommitIter(r *Repository, iter core.ObjectIter) *CommitIter { +func NewCommitIter(r *Repository, iter storer.ObjectIter) *CommitIter { return &CommitIter{iter, r} } @@ -232,7 +233,7 @@ func (iter *CommitIter) Next() (*Commit, error) { // an error happends or the end of the iter is reached. If ErrStop is sent // the iteration is stop but no error is returned. The iterator is closed. func (iter *CommitIter) ForEach(cb func(*Commit) error) error { - return iter.ObjectIter.ForEach(func(obj core.Object) error { + return iter.ObjectIter.ForEach(func(obj plumbing.Object) error { commit := &Commit{r: iter.r} if err := commit.Decode(obj); err != nil { return err diff --git a/commit_test.go b/commit_test.go index 0020172..40e8973 100644 --- a/commit_test.go +++ b/commit_test.go @@ -4,8 +4,8 @@ import ( "io" "time" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" + "gopkg.in/src-d/go-git.v4/plumbing" . "gopkg.in/check.v1" ) @@ -20,7 +20,7 @@ var _ = Suite(&SuiteCommit{}) func (s *SuiteCommit) SetUpSuite(c *C) { s.BaseSuite.SetUpSuite(c) - hash := core.NewHash("1669dce138d9b841a518c64b10914d88f5e488ea") + hash := plumbing.NewHash("1669dce138d9b841a518c64b10914d88f5e488ea") var err error s.Commit, err = s.Repository.Commit(hash) @@ -28,8 +28,8 @@ func (s *SuiteCommit) SetUpSuite(c *C) { } func (s *SuiteCommit) TestDecodeNonCommit(c *C) { - hash := core.NewHash("9a48f23120e880dfbe41f7c9b7b708e9ee62a492") - blob, err := s.Repository.s.Object(core.AnyObject, hash) + hash := plumbing.NewHash("9a48f23120e880dfbe41f7c9b7b708e9ee62a492") + blob, err := s.Repository.s.Object(plumbing.AnyObject, hash) c.Assert(err, IsNil) commit := &Commit{} @@ -38,7 +38,7 @@ func (s *SuiteCommit) TestDecodeNonCommit(c *C) { } func (s *SuiteCommit) TestType(c *C) { - c.Assert(s.Commit.Type(), Equals, core.CommitObject) + c.Assert(s.Commit.Type(), Equals, plumbing.CommitObject) } func (s *SuiteCommit) TestTree(c *C) { @@ -72,24 +72,24 @@ func (s *SuiteCommit) TestCommitEncodeDecodeIdempotent(c *C) { Author: Signature{Name: "Foo", Email: "foo@example.local", When: ts}, Committer: Signature{Name: "Bar", Email: "bar@example.local", When: ts}, Message: "Message\n\nFoo\nBar\nWith trailing blank lines\n\n", - tree: core.NewHash("f000000000000000000000000000000000000001"), - parents: []core.Hash{core.NewHash("f000000000000000000000000000000000000002")}, + tree: plumbing.NewHash("f000000000000000000000000000000000000001"), + parents: []plumbing.Hash{plumbing.NewHash("f000000000000000000000000000000000000002")}, }, { Author: Signature{Name: "Foo", Email: "foo@example.local", When: ts}, Committer: Signature{Name: "Bar", Email: "bar@example.local", When: ts}, Message: "Message\n\nFoo\nBar\nWith no trailing blank lines", - tree: core.NewHash("0000000000000000000000000000000000000003"), - parents: []core.Hash{ - core.NewHash("f000000000000000000000000000000000000004"), - core.NewHash("f000000000000000000000000000000000000005"), - core.NewHash("f000000000000000000000000000000000000006"), - core.NewHash("f000000000000000000000000000000000000007"), + tree: plumbing.NewHash("0000000000000000000000000000000000000003"), + parents: []plumbing.Hash{ + plumbing.NewHash("f000000000000000000000000000000000000004"), + plumbing.NewHash("f000000000000000000000000000000000000005"), + plumbing.NewHash("f000000000000000000000000000000000000006"), + plumbing.NewHash("f000000000000000000000000000000000000007"), }, }, } for _, commit := range commits { - obj := &core.MemoryObject{} + obj := &plumbing.MemoryObject{} err = commit.Encode(obj) c.Assert(err, IsNil) newCommit := &Commit{} @@ -130,7 +130,7 @@ func (s *SuiteCommit) TestString(c *C) { } func (s *SuiteCommit) TestStringMultiLine(c *C) { - hash := core.NewHash("e7d896db87294e33ca3202e536d4d9bb16023db3") + hash := plumbing.NewHash("e7d896db87294e33ca3202e536d4d9bb16023db3") s.buildRepositories(c, fixtures.ByURL("https://github.com/src-d/go-git.git")) diff --git a/commit_walker.go b/commit_walker.go index e595a84..8685801 100644 --- a/commit_walker.go +++ b/commit_walker.go @@ -3,11 +3,11 @@ package git import ( "io" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) type commitWalker struct { - seen map[core.Hash]bool + seen map[plumbing.Hash]bool stack []*CommitIter start *Commit cb func(*Commit) error @@ -16,7 +16,7 @@ type commitWalker struct { // WalkCommitHistory walks the commit history func WalkCommitHistory(c *Commit, cb func(*Commit) error) error { w := &commitWalker{ - seen: make(map[core.Hash]bool), + seen: make(map[plumbing.Hash]bool), stack: make([]*CommitIter, 0), start: c, cb: cb, @@ -5,7 +5,7 @@ import ( "strings" "gopkg.in/src-d/go-git.v4/config" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing/storer" ) // Storer is a generic storage of objects, references and any information @@ -13,8 +13,8 @@ import ( // information in an system directory (such as `.git`) and others // implementations are in memmory being ephemeral type Storer interface { - core.ObjectStorer - core.ReferenceStorer + storer.ObjectStorer + storer.ReferenceStorer config.ConfigStorer } diff --git a/common_test.go b/common_test.go index 672a157..95282ea 100644 --- a/common_test.go +++ b/common_test.go @@ -6,12 +6,12 @@ import ( "os" "testing" - "gopkg.in/src-d/go-git.v4/clients" - "gopkg.in/src-d/go-git.v4/clients/common" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" - "gopkg.in/src-d/go-git.v4/formats/packfile" - "gopkg.in/src-d/go-git.v4/formats/packp" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/client" + "gopkg.in/src-d/go-git.v4/plumbing/client/common" + "gopkg.in/src-d/go-git.v4/plumbing/format/packfile" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp" "gopkg.in/src-d/go-git.v4/storage/filesystem" . "gopkg.in/check.v1" @@ -94,17 +94,17 @@ func (p *MockGitUploadPackService) Info() (*common.GitUploadPackInfo, error) { c := packp.NewCapabilities() c.Decode("6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEADmulti_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master agent=git/2:2.4.8~dbussink-fix-enterprise-tokens-compilation-1167-gc7006cf") - ref := core.ReferenceName("refs/heads/master") - branch := core.ReferenceName("refs/heads/branch") - tag := core.ReferenceName("refs/tags/v1.0.0") + ref := plumbing.ReferenceName("refs/heads/master") + branch := plumbing.ReferenceName("refs/heads/branch") + tag := plumbing.ReferenceName("refs/tags/v1.0.0") return &common.GitUploadPackInfo{ Capabilities: c, - Refs: map[core.ReferenceName]*core.Reference{ - core.HEAD: core.NewSymbolicReference(core.HEAD, ref), - ref: core.NewHashReference(ref, h), - tag: core.NewHashReference(tag, h), - branch: core.NewHashReference(branch, core.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881")), + Refs: map[plumbing.ReferenceName]*plumbing.Reference{ + plumbing.HEAD: plumbing.NewSymbolicReference(plumbing.HEAD, ref), + ref: plumbing.NewHashReference(ref, h), + tag: plumbing.NewHashReference(tag, h), + branch: plumbing.NewHashReference(branch, plumbing.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881")), }, }, nil } diff --git a/config/refspec.go b/config/refspec.go index 0f41c5a..fd0aa3d 100644 --- a/config/refspec.go +++ b/config/refspec.go @@ -3,7 +3,7 @@ package config import ( "strings" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) const ( @@ -57,8 +57,8 @@ func (s RefSpec) Src() string { return spec[start:end] } -// Match match the given core.ReferenceName against the source -func (s RefSpec) Match(n core.ReferenceName) bool { +// Match match the given plumbing.ReferenceName against the source +func (s RefSpec) Match(n plumbing.ReferenceName) bool { if !s.IsWildcard() { return s.matchExact(n) } @@ -71,11 +71,11 @@ func (s RefSpec) IsWildcard() bool { return strings.Index(string(s), refSpecWildcard) != -1 } -func (s RefSpec) matchExact(n core.ReferenceName) bool { +func (s RefSpec) matchExact(n plumbing.ReferenceName) bool { return s.Src() == n.String() } -func (s RefSpec) matchGlob(n core.ReferenceName) bool { +func (s RefSpec) matchGlob(n plumbing.ReferenceName) bool { src := s.Src() name := n.String() wildcard := strings.Index(src, refSpecWildcard) @@ -92,14 +92,14 @@ func (s RefSpec) matchGlob(n core.ReferenceName) bool { } // Dst returns the destination for the given remote reference -func (s RefSpec) Dst(n core.ReferenceName) core.ReferenceName { +func (s RefSpec) Dst(n plumbing.ReferenceName) plumbing.ReferenceName { spec := string(s) start := strings.Index(spec, refSpecSeparator) + 1 dst := spec[start:] src := s.Src() if !s.IsWildcard() { - return core.ReferenceName(dst) + return plumbing.ReferenceName(dst) } name := n.String() @@ -107,7 +107,7 @@ func (s RefSpec) Dst(n core.ReferenceName) core.ReferenceName { wd := strings.Index(dst, refSpecWildcard) match := name[ws : len(name)-(len(src)-(ws+1))] - return core.ReferenceName(dst[0:wd] + match + dst[wd+1:]) + return plumbing.ReferenceName(dst[0:wd] + match + dst[wd+1:]) } func (s RefSpec) String() string { @@ -115,7 +115,7 @@ func (s RefSpec) String() string { } // MatchAny returns true if any of the RefSpec match with the given ReferenceName -func MatchAny(l []RefSpec, n core.ReferenceName) bool { +func MatchAny(l []RefSpec, n plumbing.ReferenceName) bool { for _, r := range l { if r.Match(n) { return true diff --git a/config/refspec_test.go b/config/refspec_test.go index 632f5a4..f0d1a0e 100644 --- a/config/refspec_test.go +++ b/config/refspec_test.go @@ -4,7 +4,7 @@ import ( "testing" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) type RefSpecSuite struct{} @@ -42,20 +42,20 @@ func (s *RefSpecSuite) TestRefSpecSrc(c *C) { func (s *RefSpecSuite) TestRefSpecMatch(c *C) { spec := RefSpec("refs/heads/master:refs/remotes/origin/master") - c.Assert(spec.Match(core.ReferenceName("refs/heads/foo")), Equals, false) - c.Assert(spec.Match(core.ReferenceName("refs/heads/master")), Equals, true) + c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/foo")), Equals, false) + c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/master")), Equals, true) } func (s *RefSpecSuite) TestRefSpecMatchBlob(c *C) { spec := RefSpec("refs/heads/*:refs/remotes/origin/*") - c.Assert(spec.Match(core.ReferenceName("refs/tag/foo")), Equals, false) - c.Assert(spec.Match(core.ReferenceName("refs/heads/foo")), Equals, true) + c.Assert(spec.Match(plumbing.ReferenceName("refs/tag/foo")), Equals, false) + c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/foo")), Equals, true) } func (s *RefSpecSuite) TestRefSpecDst(c *C) { spec := RefSpec("refs/heads/master:refs/remotes/origin/master") c.Assert( - spec.Dst(core.ReferenceName("refs/heads/master")).String(), Equals, + spec.Dst(plumbing.ReferenceName("refs/heads/master")).String(), Equals, "refs/remotes/origin/master", ) } @@ -63,7 +63,7 @@ func (s *RefSpecSuite) TestRefSpecDst(c *C) { func (s *RefSpecSuite) TestRefSpecDstBlob(c *C) { spec := RefSpec("refs/heads/*:refs/remotes/origin/*") c.Assert( - spec.Dst(core.ReferenceName("refs/heads/foo")).String(), Equals, + spec.Dst(plumbing.ReferenceName("refs/heads/foo")).String(), Equals, "refs/remotes/origin/foo", ) } @@ -73,7 +73,7 @@ func (s *RefSpecSuite) TestMatchAny(c *C) { "refs/heads/foo:refs/remotes/origin/bar", } - c.Assert(MatchAny(specs, core.ReferenceName("refs/heads/foo")), Equals, true) - c.Assert(MatchAny(specs, core.ReferenceName("refs/heads/bar")), Equals, true) - c.Assert(MatchAny(specs, core.ReferenceName("refs/heads/master")), Equals, false) + c.Assert(MatchAny(specs, plumbing.ReferenceName("refs/heads/foo")), Equals, true) + c.Assert(MatchAny(specs, plumbing.ReferenceName("refs/heads/bar")), Equals, true) + c.Assert(MatchAny(specs, plumbing.ReferenceName("refs/heads/master")), Equals, false) } diff --git a/core/object_test.go b/core/object_test.go deleted file mode 100644 index 5ebf26a..0000000 --- a/core/object_test.go +++ /dev/null @@ -1,176 +0,0 @@ -package core - -import ( - "fmt" - - . "gopkg.in/check.v1" -) - -type ObjectSuite struct{} - -var _ = Suite(&ObjectSuite{}) - -func (s *ObjectSuite) TestObjectTypeString(c *C) { - c.Assert(CommitObject.String(), Equals, "commit") - c.Assert(TreeObject.String(), Equals, "tree") - c.Assert(BlobObject.String(), Equals, "blob") - c.Assert(TagObject.String(), Equals, "tag") - c.Assert(REFDeltaObject.String(), Equals, "ref-delta") - c.Assert(OFSDeltaObject.String(), Equals, "ofs-delta") - c.Assert(AnyObject.String(), Equals, "any") - c.Assert(ObjectType(42).String(), Equals, "unknown") -} - -func (s *ObjectSuite) TestObjectTypeBytes(c *C) { - c.Assert(CommitObject.Bytes(), DeepEquals, []byte("commit")) -} - -func (s *ObjectSuite) TestObjectTypeValid(c *C) { - c.Assert(CommitObject.Valid(), Equals, true) - c.Assert(ObjectType(42).Valid(), Equals, false) -} - -func (s *ObjectSuite) TestParseObjectType(c *C) { - for s, e := range map[string]ObjectType{ - "commit": CommitObject, - "tree": TreeObject, - "blob": BlobObject, - "tag": TagObject, - "ref-delta": REFDeltaObject, - "ofs-delta": OFSDeltaObject, - } { - t, err := ParseObjectType(s) - c.Assert(err, IsNil) - c.Assert(e, Equals, t) - } - - t, err := ParseObjectType("foo") - c.Assert(err, Equals, ErrInvalidType) - c.Assert(t, Equals, InvalidObject) -} - -func (s *ObjectSuite) TestMultiObjectIterNext(c *C) { - expected := []Object{ - &MemoryObject{}, - &MemoryObject{}, - &MemoryObject{}, - &MemoryObject{}, - &MemoryObject{}, - &MemoryObject{}, - } - - iter := NewMultiObjectIter([]ObjectIter{ - NewObjectSliceIter(expected[0:2]), - NewObjectSliceIter(expected[2:4]), - NewObjectSliceIter(expected[4:5]), - }) - - var i int - iter.ForEach(func(o Object) error { - c.Assert(o, Equals, expected[i]) - i++ - return nil - }) - - iter.Close() -} - -func (s *ObjectSuite) TestObjectLookupIter(c *C) { - h := []Hash{ - NewHash("0920f02906615b285040767a67c5cb30fe0f5e2c"), - NewHash("4921e391f1128010a2d957f8db15c5e729ccf94a"), - } - - var count int - - i := NewObjectLookupIter(&MockObjectStorage{}, CommitObject, h) - err := i.ForEach(func(o Object) error { - c.Assert(o, NotNil) - c.Assert(o.Hash().String(), Equals, h[count].String()) - count++ - return nil - }) - - c.Assert(err, IsNil) - i.Close() -} - -func (s *ObjectSuite) TestObjectSliceIter(c *C) { - h := []Hash{ - NewHash("0920f02906615b285040767a67c5cb30fe0f5e2c"), - NewHash("4921e391f1128010a2d957f8db15c5e729ccf94a"), - } - - var count int - - i := NewObjectSliceIter([]Object{ - &MemoryObject{h: h[0]}, &MemoryObject{h: h[1]}, - }) - - err := i.ForEach(func(o Object) error { - c.Assert(o, NotNil) - c.Assert(o.Hash().String(), Equals, h[count].String()) - count++ - return nil - }) - - c.Assert(count, Equals, 2) - c.Assert(err, IsNil) - c.Assert(i.series, HasLen, 0) -} - -func (s *ObjectSuite) TestObjectSliceIterStop(c *C) { - h := []Hash{ - NewHash("0920f02906615b285040767a67c5cb30fe0f5e2c"), - NewHash("4921e391f1128010a2d957f8db15c5e729ccf94a"), - } - - i := NewObjectSliceIter([]Object{ - &MemoryObject{h: h[0]}, &MemoryObject{h: h[1]}, - }) - - var count = 0 - err := i.ForEach(func(o Object) error { - c.Assert(o, NotNil) - c.Assert(o.Hash().String(), Equals, h[count].String()) - count++ - return ErrStop - }) - - c.Assert(count, Equals, 1) - c.Assert(err, IsNil) -} - -func (s *ObjectSuite) TestObjectSliceIterError(c *C) { - i := NewObjectSliceIter([]Object{ - &MemoryObject{h: NewHash("4921e391f1128010a2d957f8db15c5e729ccf94a")}, - }) - - err := i.ForEach(func(Object) error { - return fmt.Errorf("a random error") - }) - - c.Assert(err, NotNil) -} - -type MockObjectStorage struct{} - -func (o *MockObjectStorage) NewObject() Object { - return nil -} - -func (o *MockObjectStorage) SetObject(obj Object) (Hash, error) { - return ZeroHash, nil -} - -func (o *MockObjectStorage) Object(t ObjectType, h Hash) (Object, error) { - return &MemoryObject{h: h}, nil -} - -func (o *MockObjectStorage) IterObjects(t ObjectType) (ObjectIter, error) { - return nil, nil -} - -func (o *MockObjectStorage) Begin() Transaction { - return nil -} diff --git a/core/storage.go b/core/storage.go deleted file mode 100644 index 101115b..0000000 --- a/core/storage.go +++ /dev/null @@ -1,83 +0,0 @@ -package core - -import ( - "errors" - "io" -) - -var ( - //ErrStop is used to stop a ForEach function in an Iter - ErrStop = errors.New("stop iter") -) - -// ObjectStorer generic storage of objects -type ObjectStorer interface { - // NewObject returns a new Object, the real type of the object can be a - // custom implementation or the defaul one, MemoryObject - NewObject() Object - // SetObject save an object into the storage, the object shuld be create - // with the NewObject, method, and file if the type is not supported. - SetObject(Object) (Hash, error) - // Object an object by hash with the given ObjectType. Implementors - // should return (nil, ErrObjectNotFound) if an object doesn't exist with - // both the given hash and object type. - // - // Valid ObjectType values are CommitObject, BlobObject, TagObject, - // TreeObject and AnyObject. If AnyObject is given, the object must be - // looked up regardless of its type. - Object(ObjectType, Hash) (Object, error) - // IterObjects returns a custom ObjectIter over all the object on the - // storage. - // - // Valid ObjectType values are CommitObject, BlobObject, TagObject, - IterObjects(ObjectType) (ObjectIter, error) -} - -// Transactioner is a optional method for ObjectStorer, it enable transaction -// base write and read operations in the storage -type Transactioner interface { - // Begin starts a transaction. - Begin() Transaction -} - -// PackfileWriter is a optional method for ObjectStorer, it enable direct write -// of packfile to the storage -type PackfileWriter interface { - // PackfileWriter retuns a writer for writing a packfile to the Storage, - // this method is optional, if not implemented the ObjectStorer should - // return a ErrNotImplemented error. - // - // If the implementation not implements Writer the objects should be written - // using the Set method. - PackfileWriter() (io.WriteCloser, error) -} - -// ObjectIter is a generic closable interface for iterating over objects. -type ObjectIter interface { - Next() (Object, error) - ForEach(func(Object) error) error - Close() -} - -// Transaction is an in-progress storage transaction. A transaction must end -// with a call to Commit or Rollback. -type Transaction interface { - SetObject(Object) (Hash, error) - Object(ObjectType, Hash) (Object, error) - Commit() error - Rollback() error -} - -// ReferenceStorer generic storage of references -type ReferenceStorer interface { - SetReference(*Reference) error - Reference(ReferenceName) (*Reference, error) - IterReferences() (ReferenceIter, error) -} - -// ReferenceIter is a generic closable interface for iterating over references -type ReferenceIter interface { - Next() (*Reference, error) - ForEach(func(*Reference) error) error - Close() -} diff --git a/cshared/auth_method_cshared.go b/cshared/auth_method_cshared.go index 2219edb..9be3339 100644 --- a/cshared/auth_method_cshared.go +++ b/cshared/auth_method_cshared.go @@ -6,8 +6,8 @@ import ( "strings" "golang.org/x/crypto/ssh" - "gopkg.in/src-d/go-git.v4/clients/http" - gssh "gopkg.in/src-d/go-git.v4/clients/ssh" + "gopkg.in/src-d/go-git.v4/plumbing/client/http" + gssh "gopkg.in/src-d/go-git.v4/plumbing/client/ssh" ) //export c_NewBasicAuth diff --git a/cshared/commit_cshared.go b/cshared/commit_cshared.go index 8cb91aa..756b0b2 100644 --- a/cshared/commit_cshared.go +++ b/cshared/commit_cshared.go @@ -8,8 +8,9 @@ import ( "unsafe" "gopkg.in/src-d/go-git.v4" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) +import "gopkg.in/src-d/go-git.v4/plumbing/storer" //export c_Commit_get_Hash func c_Commit_get_Hash(c uint64) *C.char { @@ -130,7 +131,7 @@ func c_Commit_Decode(o uint64) (uint64, int, *C.char) { if !ok { return IH, ErrorCodeNotFound, C.CString(MessageNotFound) } - cobj := obj.(*core.Object) + cobj := obj.(*plumbing.Object) err := commit.Decode(*cobj) if err != nil { return IH, ErrorCodeInternal, C.CString(err.Error()) @@ -196,7 +197,7 @@ func c_NewCommitIter(r uint64, iter uint64) uint64 { if !ok { return IH } - obj_iter := obj.(*core.ObjectIter) + obj_iter := obj.(*storer.ObjectIter) commit_iter := git.NewCommitIter(repo, *obj_iter) handle := RegisterObject(commit_iter) return uint64(handle) diff --git a/cshared/file_cshared.go b/cshared/file_cshared.go index 8191289..8ef6427 100644 --- a/cshared/file_cshared.go +++ b/cshared/file_cshared.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "gopkg.in/src-d/go-git.v4" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) //export c_File_get_Name @@ -55,7 +55,7 @@ func c_File_Decode(o uint64) uint64 { if !ok { return IH } - cobj := obj.(*core.Object) + cobj := obj.(*plumbing.Object) file := git.File{} file.Decode(*cobj) return uint64(RegisterObject(&file)) diff --git a/cshared/objects_cshared.go b/cshared/objects_cshared.go index 2600555..54b9426 100644 --- a/cshared/objects_cshared.go +++ b/cshared/objects_cshared.go @@ -7,7 +7,7 @@ import ( "time" "gopkg.in/src-d/go-git.v4" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) //export c_Signature_Name @@ -73,7 +73,7 @@ func c_Blob_Decode(o uint64) uint64 { if !ok { return IH } - cobj := obj.(*core.Object) + cobj := obj.(*plumbing.Object) blob := git.Blob{} blob.Decode(*cobj) return uint64(RegisterObject(&blob)) diff --git a/cshared/repository_cshared.go b/cshared/repository_cshared.go index e11a6c0..76755bf 100644 --- a/cshared/repository_cshared.go +++ b/cshared/repository_cshared.go @@ -83,7 +83,7 @@ func c_Repository_set_Storage(r uint64, val uint64) { if !ok { return } - repo.Storage = *obj.(*core.ObjectStorage) + repo.Storage = *obj.(*plumbing.ObjectStorage) } //export c_Repository_Pull @@ -121,7 +121,7 @@ func c_Repository_Commit(r uint64, h []byte) (uint64, int, *C.char) { return IH, ErrorCodeNotFound, C.CString(MessageNotFound) } repo := obj.(*git.Repository) - var hash core.Hash + var hash plumbing.Hash copy(hash[:], h) commit, err := repo.Commit(hash) if err != nil { @@ -153,7 +153,7 @@ func c_Repository_Tree(r uint64, h []byte) (uint64, int, *C.char) { return IH, ErrorCodeNotFound, C.CString(MessageNotFound) } repo := obj.(*git.Repository) - var hash core.Hash + var hash plumbing.Hash copy(hash[:], h) tree, err := repo.Tree(hash) if err != nil { @@ -170,7 +170,7 @@ func c_Repository_Blob(r uint64, h []byte) (uint64, int, *C.char) { return IH, ErrorCodeNotFound, C.CString(MessageNotFound) } repo := obj.(*git.Repository) - var hash core.Hash + var hash plumbing.Hash copy(hash[:], h) blob, err := repo.Blob(hash) if err != nil { @@ -187,7 +187,7 @@ func c_Repository_Tag(r uint64, h []byte) (uint64, int, *C.char) { return IH, ErrorCodeNotFound, C.CString(MessageNotFound) } repo := obj.(*git.Repository) - var hash core.Hash + var hash plumbing.Hash copy(hash[:], h) tag, err := repo.Tag(hash) if err != nil { @@ -219,7 +219,7 @@ func c_Repository_Object(r uint64, h []byte) (uint64, int, *C.char) { return IH, ErrorCodeNotFound, C.CString(MessageNotFound) } repo := obj.(*git.Repository) - var hash core.Hash + var hash plumbing.Hash copy(hash[:], h) robj, err := repo.Object(hash) if err != nil { diff --git a/cshared/tag_cshared.go b/cshared/tag_cshared.go index 67c3ada..dd0814a 100644 --- a/cshared/tag_cshared.go +++ b/cshared/tag_cshared.go @@ -6,8 +6,9 @@ import ( "io" "gopkg.in/src-d/go-git.v4" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) +import "gopkg.in/src-d/go-git.v4/plumbing/storer" func c_Tag_get_Hash(t uint64) *C.char { obj, ok := GetObject(Handle(t)) @@ -79,7 +80,7 @@ func c_Tag_Decode(o uint64) (uint64, int, *C.char) { if !ok { return IH, ErrorCodeNotFound, C.CString(MessageNotFound) } - cobj := obj.(*core.Object) + cobj := obj.(*plumbing.Object) tag := git.Tag{} err := tag.Decode(*cobj) if err != nil { @@ -165,7 +166,7 @@ func c_NewTagIter(r uint64, i uint64) uint64 { if !ok { return IH } - iter := obj.(*core.ObjectIter) + iter := obj.(*storer.ObjectIter) return uint64(RegisterObject(git.NewTagIter(repo, *iter))) } diff --git a/cshared/tree_cshared.go b/cshared/tree_cshared.go index 4974904..8533f60 100644 --- a/cshared/tree_cshared.go +++ b/cshared/tree_cshared.go @@ -10,7 +10,7 @@ package main import ( //line /home/mcuadros/workspace/go/src/gopkg.in/src-d/go-git.v4/cshared/tree_cshared.go:7 "gopkg.in/src-d/go-git.v4" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) //line /home/mcuadros/workspace/go/src/gopkg.in/src-d/go-git.v4/cshared/tree_cshared.go:13 @@ -99,7 +99,7 @@ func c_Tree_Decode(o uint64) (uint64, int, *_Ctype_char) { if !ok { return IH, ErrorCodeNotFound, _Cfunc_CString(MessageNotFound) } - cobj := obj.(*core.Object) + cobj := obj.(*plumbing.Object) tree := git.Tree{} err := tree.Decode(*cobj) if err != nil { diff --git a/examples/remotes/main.go b/examples/remotes/main.go index 552d6a5..3ccecd7 100644 --- a/examples/remotes/main.go +++ b/examples/remotes/main.go @@ -7,7 +7,7 @@ import ( "gopkg.in/src-d/go-git.v4" "gopkg.in/src-d/go-git.v4/config" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) func main() { @@ -46,10 +46,10 @@ func main() { color.Blue("git show-ref") refs, _ := r.Refs() - refs.ForEach(func(ref *core.Reference) error { + refs.ForEach(func(ref *plumbing.Reference) error { // The HEAD is ommitted in a `git show-ref` so we ignore the symbolic // references, the HEAD - if ref.Type() == core.SymbolicReference { + if ref.Type() == plumbing.SymbolicReference { return nil } diff --git a/examples/storage/aerospike/storage.go b/examples/storage/aerospike/storage.go index 776fc33..a1d8c00 100644 --- a/examples/storage/aerospike/storage.go +++ b/examples/storage/aerospike/storage.go @@ -7,7 +7,8 @@ import ( "io/ioutil" "gopkg.in/src-d/go-git.v4/config" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" driver "github.com/aerospike/aerospike-client-go" ) @@ -32,11 +33,11 @@ func NewStorage(client *driver.Client, ns, url string) (*Storage, error) { return &Storage{client: client, ns: ns, url: url}, nil } -func (s *Storage) NewObject() core.Object { - return &core.MemoryObject{} +func (s *Storage) NewObject() plumbing.Object { + return &plumbing.MemoryObject{} } -func (s *Storage) SetObject(obj core.Object) (core.Hash, error) { +func (s *Storage) SetObject(obj plumbing.Object) (plumbing.Hash, error) { key, err := s.buildKey(obj.Hash(), obj.Type()) if err != nil { return obj.Hash(), err @@ -63,7 +64,7 @@ func (s *Storage) SetObject(obj core.Object) (core.Hash, error) { return obj.Hash(), err } -func (s *Storage) Object(t core.ObjectType, h core.Hash) (core.Object, error) { +func (s *Storage) Object(t plumbing.ObjectType, h plumbing.Hash) (plumbing.Object, error) { key, err := s.buildKey(h, t) if err != nil { return nil, err @@ -75,13 +76,13 @@ func (s *Storage) Object(t core.ObjectType, h core.Hash) (core.Object, error) { } if rec == nil { - return nil, core.ErrObjectNotFound + return nil, plumbing.ErrObjectNotFound } return objectFromRecord(rec, t) } -func (s *Storage) IterObjects(t core.ObjectType) (core.ObjectIter, error) { +func (s *Storage) IterObjects(t plumbing.ObjectType) (storer.ObjectIter, error) { stmnt := driver.NewStatement(s.ns, t.String()) err := stmnt.Addfilter(driver.NewEqualFilter(urlField, s.url)) @@ -93,16 +94,16 @@ func (s *Storage) IterObjects(t core.ObjectType) (core.ObjectIter, error) { return &ObjectIter{t, rs.Records}, nil } -func (s *Storage) buildKey(h core.Hash, t core.ObjectType) (*driver.Key, error) { +func (s *Storage) buildKey(h plumbing.Hash, t plumbing.ObjectType) (*driver.Key, error) { return driver.NewKey(s.ns, t.String(), fmt.Sprintf("%s|%s", s.url, h.String())) } type ObjectIter struct { - t core.ObjectType + t plumbing.ObjectType ch chan *driver.Record } -func (i *ObjectIter) Next() (core.Object, error) { +func (i *ObjectIter) Next() (plumbing.Object, error) { r := <-i.ch if r == nil { return nil, io.EOF @@ -111,7 +112,7 @@ func (i *ObjectIter) Next() (core.Object, error) { return objectFromRecord(r, i.t) } -func (i *ObjectIter) ForEach(cb func(obj core.Object) error) error { +func (i *ObjectIter) ForEach(cb func(obj plumbing.Object) error) error { for { obj, err := i.Next() if err != nil { @@ -123,7 +124,7 @@ func (i *ObjectIter) ForEach(cb func(obj core.Object) error) error { } if err := cb(obj); err != nil { - if err == core.ErrStop { + if err == storer.ErrStop { return nil } @@ -134,10 +135,10 @@ func (i *ObjectIter) ForEach(cb func(obj core.Object) error) error { func (i *ObjectIter) Close() {} -func objectFromRecord(r *driver.Record, t core.ObjectType) (core.Object, error) { +func objectFromRecord(r *driver.Record, t plumbing.ObjectType) (plumbing.Object, error) { content := r.Bins["blob"].([]byte) - o := &core.MemoryObject{} + o := &plumbing.MemoryObject{} o.SetType(t) o.SetSize(int64(len(content))) @@ -149,7 +150,7 @@ func objectFromRecord(r *driver.Record, t core.ObjectType) (core.Object, error) return o, nil } -func (s *Storage) SetReference(ref *core.Reference) error { +func (s *Storage) SetReference(ref *plumbing.Reference) error { key, err := s.buildReferenceKey(ref.Name()) if err != nil { return err @@ -165,7 +166,7 @@ func (s *Storage) SetReference(ref *core.Reference) error { return s.client.Put(nil, key, bins) } -func (s *Storage) Reference(n core.ReferenceName) (*core.Reference, error) { +func (s *Storage) Reference(n plumbing.ReferenceName) (*plumbing.Reference, error) { key, err := s.buildReferenceKey(n) if err != nil { return nil, err @@ -176,17 +177,17 @@ func (s *Storage) Reference(n core.ReferenceName) (*core.Reference, error) { return nil, err } - return core.NewReferenceFromStrings( + return plumbing.NewReferenceFromStrings( rec.Bins["name"].(string), rec.Bins["target"].(string), ), nil } -func (s *Storage) buildReferenceKey(n core.ReferenceName) (*driver.Key, error) { +func (s *Storage) buildReferenceKey(n plumbing.ReferenceName) (*driver.Key, error) { return driver.NewKey(s.ns, referencesSet, fmt.Sprintf("%s|%s", s.url, n)) } -func (s *Storage) IterReferences() (core.ReferenceIter, error) { +func (s *Storage) IterReferences() (storer.ReferenceIter, error) { stmnt := driver.NewStatement(s.ns, referencesSet) err := stmnt.Addfilter(driver.NewEqualFilter(urlField, s.url)) if err != nil { @@ -198,15 +199,15 @@ func (s *Storage) IterReferences() (core.ReferenceIter, error) { return nil, err } - var refs []*core.Reference + var refs []*plumbing.Reference for r := range rs.Records { - refs = append(refs, core.NewReferenceFromStrings( + refs = append(refs, plumbing.NewReferenceFromStrings( r.Bins["name"].(string), r.Bins["target"].(string), )) } - return core.NewReferenceSliceIter(refs), nil + return storer.NewReferenceSliceIter(refs), nil } func (s *Storage) Config() (*config.Config, error) { @@ -251,10 +252,10 @@ func createIndexes(c *driver.Client, ns string) error { for _, set := range [...]string{ referencesSet, configSet, - core.BlobObject.String(), - core.TagObject.String(), - core.TreeObject.String(), - core.CommitObject.String(), + plumbing.BlobObject.String(), + plumbing.TagObject.String(), + plumbing.TreeObject.String(), + plumbing.CommitObject.String(), } { if err := createIndex(c, ns, set); err != nil { return err @@ -6,7 +6,7 @@ import ( "os" "strings" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing/storer" ) // File represents git file objects. @@ -83,7 +83,7 @@ func (iter *FileIter) Next() (*File, error) { } // ForEach call the cb function for each file contained on this iter until -// an error happends or the end of the iter is reached. If core.ErrStop is sent +// an error happends or the end of the iter is reached. If plumbing.ErrStop is sent // the iteration is stop but no error is returned. The iterator is closed. func (iter *FileIter) ForEach(cb func(*File) error) error { defer iter.Close() @@ -99,7 +99,7 @@ func (iter *FileIter) ForEach(cb func(*File) error) error { } if err := cb(f); err != nil { - if err == core.ErrStop { + if err == storer.ErrStop { return nil } diff --git a/file_test.go b/file_test.go index 01ad8ca..ca815c2 100644 --- a/file_test.go +++ b/file_test.go @@ -3,8 +3,9 @@ package git import ( "io" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" . "gopkg.in/check.v1" ) @@ -42,7 +43,7 @@ var fileIterTests = []struct { func (s *FileSuite) TestIter(c *C) { for i, t := range fileIterTests { r := s.Repositories[t.repo] - commit, err := r.Commit(core.NewHash(t.commit)) + commit, err := r.Commit(plumbing.NewHash(t.commit)) c.Assert(err, IsNil, Commentf("subtest %d: %v (%s)", i, err, t.commit)) tree, err := commit.Tree() @@ -99,7 +100,7 @@ hs_err_pid* func (s *FileSuite) TestContents(c *C) { for i, t := range contentsTests { - commit, err := s.Repositories[t.repo].Commit(core.NewHash(t.commit)) + commit, err := s.Repositories[t.repo].Commit(plumbing.NewHash(t.commit)) c.Assert(err, IsNil, Commentf("subtest %d: %v (%s)", i, err, t.commit)) file, err := commit.File(t.path) @@ -151,7 +152,7 @@ func (s *FileSuite) TestLines(c *C) { r, ok := s.Repositories[t.repo] c.Assert(ok, Equals, true, Commentf("cannot find repository %s", t.repo)) - commit, err := r.Commit(core.NewHash(t.commit)) + commit, err := r.Commit(plumbing.NewHash(t.commit)) c.Assert(err, IsNil, Commentf("subtest %d: %v (%s)", i, err, t.commit)) file, err := commit.File(t.path) @@ -183,7 +184,7 @@ func (s *FileSuite) TestIgnoreEmptyDirEntries(c *C) { s.buildRepositories(c, fixtures.ByTag("empty-folder")) for i, t := range ignoreEmptyDirEntriesTests { - commit, err := s.Repositories[t.repo].Commit(core.NewHash(t.commit)) + commit, err := s.Repositories[t.repo].Commit(plumbing.NewHash(t.commit)) c.Assert(err, IsNil, Commentf("subtest %d: %v (%s)", i, err, t.commit)) tree, err := commit.Tree() @@ -199,7 +200,7 @@ func (s *FileSuite) TestIgnoreEmptyDirEntries(c *C) { } func (s *FileSuite) TestFileIter(c *C) { - hash := core.NewHash("1669dce138d9b841a518c64b10914d88f5e488ea") + hash := plumbing.NewHash("1669dce138d9b841a518c64b10914d88f5e488ea") commit, err := s.Repository.Commit(hash) c.Assert(err, IsNil) @@ -227,7 +228,7 @@ func (s *FileSuite) TestFileIter(c *C) { i = tree.Files() i.ForEach(func(f *File) error { count++ - return core.ErrStop + return storer.ErrStop }) c.Assert(count, Equals, 1) diff --git a/fixtures/fixtures.go b/fixtures/fixtures.go index 929fb5c..324f2da 100644 --- a/fixtures/fixtures.go +++ b/fixtures/fixtures.go @@ -9,7 +9,7 @@ import ( "github.com/alcortesm/tgz" "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/utils/fs" osfs "gopkg.in/src-d/go-git.v4/utils/fs/os" ) @@ -23,98 +23,98 @@ var folders []string var fixtures = Fixtures{{ Tags: []string{"packfile", "ofs-delta", ".git"}, URL: "https://github.com/git-fixtures/basic.git", - Head: core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), - PackfileHash: core.NewHash("a3fed42da1e8189a077c0e6846c040dcf73fc9dd"), - DotGitHash: core.NewHash("0a00a25543e6d732dbf4e8e9fec55c8e65fc4e8d"), + Head: plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), + PackfileHash: plumbing.NewHash("a3fed42da1e8189a077c0e6846c040dcf73fc9dd"), + DotGitHash: plumbing.NewHash("0a00a25543e6d732dbf4e8e9fec55c8e65fc4e8d"), ObjectsCount: 31, }, { Tags: []string{"packfile", "ref-delta", ".git"}, URL: "https://github.com/git-fixtures/basic.git", - Head: core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), - PackfileHash: core.NewHash("c544593473465e6315ad4182d04d366c4592b829"), - DotGitHash: core.NewHash("7cbde0ca02f13aedd5ec8b358ca17b1c0bf5ee64"), + Head: plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), + PackfileHash: plumbing.NewHash("c544593473465e6315ad4182d04d366c4592b829"), + DotGitHash: plumbing.NewHash("7cbde0ca02f13aedd5ec8b358ca17b1c0bf5ee64"), ObjectsCount: 31, }, { Tags: []string{"packfile", "ofs-delta", ".git", "single-branch"}, URL: "https://github.com/git-fixtures/basic.git", - Head: core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), - PackfileHash: core.NewHash("61f0ee9c75af1f9678e6f76ff39fbe372b6f1c45"), - DotGitHash: core.NewHash("21504f6d2cc2ef0c9d6ebb8802c7b49abae40c1a"), + Head: plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), + PackfileHash: plumbing.NewHash("61f0ee9c75af1f9678e6f76ff39fbe372b6f1c45"), + DotGitHash: plumbing.NewHash("21504f6d2cc2ef0c9d6ebb8802c7b49abae40c1a"), ObjectsCount: 28, }, { Tags: []string{".git", "merge-conflict"}, URL: "https://github.com/git-fixtures/basic.git", - DotGitHash: core.NewHash("4870d54b5b04e43da8cf99ceec179d9675494af8"), + DotGitHash: plumbing.NewHash("4870d54b5b04e43da8cf99ceec179d9675494af8"), }, { Tags: []string{".git", "resolve-undo"}, URL: "https://github.com/git-fixtures/basic.git", - DotGitHash: core.NewHash("df6781fd40b8f4911d70ce71f8387b991615cd6d"), + DotGitHash: plumbing.NewHash("df6781fd40b8f4911d70ce71f8387b991615cd6d"), }, { Tags: []string{".git", "intent-to-add"}, URL: "https://github.com/git-fixtures/basic.git", - DotGitHash: core.NewHash("4e7600af05c3356e8b142263e127b76f010facfc"), + DotGitHash: plumbing.NewHash("4e7600af05c3356e8b142263e127b76f010facfc"), }, { Tags: []string{".git", "index-v4"}, URL: "https://github.com/git-fixtures/basic.git", - DotGitHash: core.NewHash("935e5ac17c41c309c356639816ea0694a568c484"), + DotGitHash: plumbing.NewHash("935e5ac17c41c309c356639816ea0694a568c484"), }, { Tags: []string{"packfile", ".git", "unpacked", "multi-packfile"}, URL: "https://github.com/src-d/go-git.git", - Head: core.NewHash("e8788ad9165781196e917292d6055cba1d78664e"), - PackfileHash: core.NewHash("3559b3b47e695b33b0913237a4df3357e739831c"), - DotGitHash: core.NewHash("174be6bd4292c18160542ae6dc6704b877b8a01a"), + Head: plumbing.NewHash("e8788ad9165781196e917292d6055cba1d78664e"), + PackfileHash: plumbing.NewHash("3559b3b47e695b33b0913237a4df3357e739831c"), + DotGitHash: plumbing.NewHash("174be6bd4292c18160542ae6dc6704b877b8a01a"), ObjectsCount: 2133, }, { Tags: []string{"packfile", ".git", "tags"}, URL: "https://github.com/git-fixtures/tags.git", - Head: core.NewHash("f7b877701fbf855b44c0a9e86f3fdce2c298b07f"), - DotGitHash: core.NewHash("c0c7c57ab1753ddbd26cc45322299ddd12842794"), - PackfileHash: core.NewHash("b68617dd8637fe6409d9842825a843a1d9a6e484"), + Head: plumbing.NewHash("f7b877701fbf855b44c0a9e86f3fdce2c298b07f"), + DotGitHash: plumbing.NewHash("c0c7c57ab1753ddbd26cc45322299ddd12842794"), + PackfileHash: plumbing.NewHash("b68617dd8637fe6409d9842825a843a1d9a6e484"), ObjectsCount: 7, }, { Tags: []string{"packfile"}, URL: "https://github.com/spinnaker/spinnaker.git", - Head: core.NewHash("06ce06d0fc49646c4de733c45b7788aabad98a6f"), - PackfileHash: core.NewHash("f2e0a8889a746f7600e07d2246a2e29a72f696be"), + Head: plumbing.NewHash("06ce06d0fc49646c4de733c45b7788aabad98a6f"), + PackfileHash: plumbing.NewHash("f2e0a8889a746f7600e07d2246a2e29a72f696be"), }, { Tags: []string{"packfile"}, URL: "https://github.com/jamesob/desk.git", - Head: core.NewHash("d2313db6e7ca7bac79b819d767b2a1449abb0a5d"), - PackfileHash: core.NewHash("4ec6344877f494690fc800aceaf2ca0e86786acb"), + Head: plumbing.NewHash("d2313db6e7ca7bac79b819d767b2a1449abb0a5d"), + PackfileHash: plumbing.NewHash("4ec6344877f494690fc800aceaf2ca0e86786acb"), }, { Tags: []string{"packfile", "empty-folder"}, URL: "https://github.com/cpcs499/Final_Pres_P.git", - Head: core.NewHash("70bade703ce556c2c7391a8065c45c943e8b6bc3"), - PackfileHash: core.NewHash("29f304662fd64f102d94722cf5bd8802d9a9472c"), + Head: plumbing.NewHash("70bade703ce556c2c7391a8065c45c943e8b6bc3"), + PackfileHash: plumbing.NewHash("29f304662fd64f102d94722cf5bd8802d9a9472c"), }, { Tags: []string{"packfile", "diff-tree"}, URL: "https://github.com/github/gem-builder.git", - PackfileHash: core.NewHash("1ea0b3971fd64fdcdf3282bfb58e8cf10095e4e6"), + PackfileHash: plumbing.NewHash("1ea0b3971fd64fdcdf3282bfb58e8cf10095e4e6"), }, { Tags: []string{"packfile", "diff-tree"}, URL: "https://github.com/githubtraining/example-branches.git", - PackfileHash: core.NewHash("bb8ee94710d3fa39379a630f76812c187217b312"), + PackfileHash: plumbing.NewHash("bb8ee94710d3fa39379a630f76812c187217b312"), }, { Tags: []string{"packfile", "diff-tree"}, URL: "https://github.com/rumpkernel/rumprun-xen.git", - PackfileHash: core.NewHash("7861f2632868833a35fe5e4ab94f99638ec5129b"), + PackfileHash: plumbing.NewHash("7861f2632868833a35fe5e4ab94f99638ec5129b"), }, { Tags: []string{"packfile", "diff-tree"}, URL: "https://github.com/mcuadros/skeetr.git", - PackfileHash: core.NewHash("36ef7a2296bfd526020340d27c5e1faa805d8d38"), + PackfileHash: plumbing.NewHash("36ef7a2296bfd526020340d27c5e1faa805d8d38"), }, { Tags: []string{"packfile", "diff-tree"}, URL: "https://github.com/dezfowler/LiteMock.git", - PackfileHash: core.NewHash("0d9b6cfc261785837939aaede5986d7a7c212518"), + PackfileHash: plumbing.NewHash("0d9b6cfc261785837939aaede5986d7a7c212518"), }, { Tags: []string{"packfile", "diff-tree"}, URL: "https://github.com/tyba/storable.git", - PackfileHash: core.NewHash("0d3d824fb5c930e7e7e1f0f399f2976847d31fd3"), + PackfileHash: plumbing.NewHash("0d3d824fb5c930e7e7e1f0f399f2976847d31fd3"), }, { Tags: []string{"packfile", "diff-tree"}, URL: "https://github.com/toqueteos/ts3.git", - PackfileHash: core.NewHash("21b33a26eb7ffbd35261149fe5d886b9debab7cb"), + PackfileHash: plumbing.NewHash("21b33a26eb7ffbd35261149fe5d886b9debab7cb"), }} func All() Fixtures { @@ -137,9 +137,9 @@ func ByTag(tag string) Fixtures { type Fixture struct { URL string Tags []string - Head core.Hash - PackfileHash core.Hash - DotGitHash core.Hash + Head plumbing.Hash + PackfileHash plumbing.Hash + DotGitHash plumbing.Hash ObjectsCount int32 } diff --git a/formats/packfile/scanner_test.go b/formats/packfile/scanner_test.go deleted file mode 100644 index 5f80da0..0000000 --- a/formats/packfile/scanner_test.go +++ /dev/null @@ -1,189 +0,0 @@ -package packfile - -import ( - "bytes" - "io" - - . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/fixtures" -) - -type ScannerSuite struct { - fixtures.Suite -} - -var _ = Suite(&ScannerSuite{}) - -func (s *ScannerSuite) TestHeader(c *C) { - r := fixtures.Basic().One().Packfile() - p := NewScanner(r) - - version, objects, err := p.Header() - c.Assert(err, IsNil) - c.Assert(version, Equals, VersionSupported) - c.Assert(objects, Equals, uint32(31)) -} - -func (s *ScannerSuite) TestNextObjectHeaderWithoutHeader(c *C) { - r := fixtures.Basic().One().Packfile() - p := NewScanner(r) - - h, err := p.NextObjectHeader() - c.Assert(err, IsNil) - c.Assert(h, DeepEquals, &expectedHeadersOFS[0]) - - version, objects, err := p.Header() - c.Assert(err, IsNil) - c.Assert(version, Equals, VersionSupported) - c.Assert(objects, Equals, uint32(31)) -} - -func (s *ScannerSuite) TestNextObjectHeaderREFDelta(c *C) { - s.testNextObjectHeader(c, "ref-delta", expectedHeadersREF) -} - -func (s *ScannerSuite) TestNextObjectHeaderOFSDelta(c *C) { - s.testNextObjectHeader(c, "ofs-delta", expectedHeadersOFS) -} - -func (s *ScannerSuite) testNextObjectHeader(c *C, tag string, expected []ObjectHeader) { - r := fixtures.Basic().ByTag(tag).One().Packfile() - p := NewScanner(r) - - _, objects, err := p.Header() - c.Assert(err, IsNil) - - for i := 0; i < int(objects); i++ { - h, err := p.NextObjectHeader() - c.Assert(err, IsNil) - c.Assert(*h, DeepEquals, expected[i]) - - buf := bytes.NewBuffer(nil) - n, _, err := p.NextObject(buf) - c.Assert(err, IsNil) - c.Assert(n, Equals, h.Length) - } - - n, err := p.Checksum() - c.Assert(err, IsNil) - c.Assert(n, HasLen, 20) -} - -func (s *ScannerSuite) TestNextObjectHeaderWithOutReadObject(c *C) { - f := fixtures.Basic().ByTag("ref-delta").One() - r := f.Packfile() - p := NewScanner(r) - - _, objects, err := p.Header() - c.Assert(err, IsNil) - - for i := 0; i < int(objects); i++ { - h, _ := p.NextObjectHeader() - c.Assert(err, IsNil) - c.Assert(*h, DeepEquals, expectedHeadersREF[i]) - } - - err = p.discardObjectIfNeeded() - c.Assert(err, IsNil) - - n, err := p.Checksum() - c.Assert(err, IsNil) - c.Assert(n, Equals, f.PackfileHash) -} - -func (s *ScannerSuite) TestNextObjectHeaderWithOutReadObjectNonSeekable(c *C) { - f := fixtures.Basic().ByTag("ref-delta").One() - r := io.MultiReader(f.Packfile()) - p := NewScanner(r) - - _, objects, err := p.Header() - c.Assert(err, IsNil) - - for i := 0; i < int(objects); i++ { - h, _ := p.NextObjectHeader() - c.Assert(err, IsNil) - c.Assert(*h, DeepEquals, expectedHeadersREF[i]) - } - - err = p.discardObjectIfNeeded() - c.Assert(err, IsNil) - - n, err := p.Checksum() - c.Assert(err, IsNil) - c.Assert(n, Equals, f.PackfileHash) -} - -var expectedHeadersOFS = []ObjectHeader{ - {Type: core.CommitObject, Offset: 12, Length: 254}, - {Type: core.OFSDeltaObject, Offset: 186, Length: 93, OffsetReference: 12}, - {Type: core.CommitObject, Offset: 286, Length: 242}, - {Type: core.CommitObject, Offset: 449, Length: 242}, - {Type: core.CommitObject, Offset: 615, Length: 333}, - {Type: core.CommitObject, Offset: 838, Length: 332}, - {Type: core.CommitObject, Offset: 1063, Length: 244}, - {Type: core.CommitObject, Offset: 1230, Length: 243}, - {Type: core.CommitObject, Offset: 1392, Length: 187}, - {Type: core.BlobObject, Offset: 1524, Length: 189}, - {Type: core.BlobObject, Offset: 1685, Length: 18}, - {Type: core.BlobObject, Offset: 1713, Length: 1072}, - {Type: core.BlobObject, Offset: 2351, Length: 76110}, - {Type: core.BlobObject, Offset: 78050, Length: 2780}, - {Type: core.BlobObject, Offset: 78882, Length: 217848}, - {Type: core.BlobObject, Offset: 80725, Length: 706}, - {Type: core.BlobObject, Offset: 80998, Length: 11488}, - {Type: core.BlobObject, Offset: 84032, Length: 78}, - {Type: core.TreeObject, Offset: 84115, Length: 272}, - {Type: core.OFSDeltaObject, Offset: 84375, Length: 43, OffsetReference: 84115}, - {Type: core.TreeObject, Offset: 84430, Length: 38}, - {Type: core.TreeObject, Offset: 84479, Length: 75}, - {Type: core.TreeObject, Offset: 84559, Length: 38}, - {Type: core.TreeObject, Offset: 84608, Length: 34}, - {Type: core.BlobObject, Offset: 84653, Length: 9}, - {Type: core.OFSDeltaObject, Offset: 84671, Length: 6, OffsetReference: 84375}, - {Type: core.OFSDeltaObject, Offset: 84688, Length: 9, OffsetReference: 84375}, - {Type: core.OFSDeltaObject, Offset: 84708, Length: 6, OffsetReference: 84375}, - {Type: core.OFSDeltaObject, Offset: 84725, Length: 5, OffsetReference: 84115}, - {Type: core.OFSDeltaObject, Offset: 84741, Length: 8, OffsetReference: 84375}, - {Type: core.OFSDeltaObject, Offset: 84760, Length: 4, OffsetReference: 84741}, -} - -var expectedHeadersREF = []ObjectHeader{ - {Type: core.CommitObject, Offset: 12, Length: 254}, - {Type: core.REFDeltaObject, Offset: 186, Length: 93, - Reference: core.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881")}, - {Type: core.CommitObject, Offset: 304, Length: 242}, - {Type: core.CommitObject, Offset: 467, Length: 242}, - {Type: core.CommitObject, Offset: 633, Length: 333}, - {Type: core.CommitObject, Offset: 856, Length: 332}, - {Type: core.CommitObject, Offset: 1081, Length: 243}, - {Type: core.CommitObject, Offset: 1243, Length: 244}, - {Type: core.CommitObject, Offset: 1410, Length: 187}, - {Type: core.BlobObject, Offset: 1542, Length: 189}, - {Type: core.BlobObject, Offset: 1703, Length: 18}, - {Type: core.BlobObject, Offset: 1731, Length: 1072}, - {Type: core.BlobObject, Offset: 2369, Length: 76110}, - {Type: core.TreeObject, Offset: 78068, Length: 38}, - {Type: core.BlobObject, Offset: 78117, Length: 2780}, - {Type: core.TreeObject, Offset: 79049, Length: 75}, - {Type: core.BlobObject, Offset: 79129, Length: 217848}, - {Type: core.BlobObject, Offset: 80972, Length: 706}, - {Type: core.TreeObject, Offset: 81265, Length: 38}, - {Type: core.BlobObject, Offset: 81314, Length: 11488}, - {Type: core.TreeObject, Offset: 84752, Length: 34}, - {Type: core.BlobObject, Offset: 84797, Length: 78}, - {Type: core.TreeObject, Offset: 84880, Length: 271}, - {Type: core.REFDeltaObject, Offset: 85141, Length: 6, - Reference: core.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")}, - {Type: core.REFDeltaObject, Offset: 85176, Length: 37, - Reference: core.NewHash("fb72698cab7617ac416264415f13224dfd7a165e")}, - {Type: core.BlobObject, Offset: 85244, Length: 9}, - {Type: core.REFDeltaObject, Offset: 85262, Length: 9, - Reference: core.NewHash("fb72698cab7617ac416264415f13224dfd7a165e")}, - {Type: core.REFDeltaObject, Offset: 85300, Length: 6, - Reference: core.NewHash("fb72698cab7617ac416264415f13224dfd7a165e")}, - {Type: core.TreeObject, Offset: 85335, Length: 110}, - {Type: core.REFDeltaObject, Offset: 85448, Length: 8, - Reference: core.NewHash("eba74343e2f15d62adedfd8c883ee0262b5c8021")}, - {Type: core.TreeObject, Offset: 85485, Length: 73}, -} @@ -8,7 +8,8 @@ import ( "strconv" "time" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" ) // ErrUnsupportedObject trigger when a non-supported object is being decoded. @@ -34,13 +35,13 @@ var ErrUnsupportedObject = errors.New("unsupported object type") // } // } // -// This interface is intentionally different from core.Object, which is a lower +// This interface is intentionally different from plumbing.Object, which is a lower // level interface used by storage implementations to read and write objects. type Object interface { - ID() core.Hash - Type() core.ObjectType - Decode(core.Object) error - Encode(core.Object) error + ID() plumbing.Hash + Type() plumbing.ObjectType + Decode(plumbing.Object) error + Encode(plumbing.Object) error } // Signature represents an action signed by a person @@ -116,13 +117,13 @@ func (s *Signature) String() string { // ObjectIter provides an iterator for a set of objects. type ObjectIter struct { - core.ObjectIter + storer.ObjectIter r *Repository } // NewObjectIter returns a ObjectIter for the given repository and underlying // object iterator. -func NewObjectIter(r *Repository, iter core.ObjectIter) *ObjectIter { +func NewObjectIter(r *Repository, iter storer.ObjectIter) *ObjectIter { return &ObjectIter{iter, r} } @@ -136,7 +137,7 @@ func (iter *ObjectIter) Next() (Object, error) { } o, err := iter.toObject(obj) - if err == core.ErrInvalidType { + if err == plumbing.ErrInvalidType { continue } @@ -152,9 +153,9 @@ func (iter *ObjectIter) Next() (Object, error) { // an error happens or the end of the iter is reached. If ErrStop is sent // the iteration is stop but no error is returned. The iterator is closed. func (iter *ObjectIter) ForEach(cb func(Object) error) error { - return iter.ObjectIter.ForEach(func(obj core.Object) error { + return iter.ObjectIter.ForEach(func(obj plumbing.Object) error { o, err := iter.toObject(obj) - if err == core.ErrInvalidType { + if err == plumbing.ErrInvalidType { return nil } @@ -166,21 +167,21 @@ func (iter *ObjectIter) ForEach(cb func(Object) error) error { }) } -func (iter *ObjectIter) toObject(obj core.Object) (Object, error) { +func (iter *ObjectIter) toObject(obj plumbing.Object) (Object, error) { switch obj.Type() { - case core.BlobObject: + case plumbing.BlobObject: blob := &Blob{} return blob, blob.Decode(obj) - case core.TreeObject: + case plumbing.TreeObject: tree := &Tree{r: iter.r} return tree, tree.Decode(obj) - case core.CommitObject: + case plumbing.CommitObject: commit := &Commit{} return commit, commit.Decode(obj) - case core.TagObject: + case plumbing.TagObject: tag := &Tag{} return tag, tag.Decode(obj) default: - return nil, core.ErrInvalidType + return nil, plumbing.ErrInvalidType } } diff --git a/objects_test.go b/objects_test.go index ee77869..78ebc6a 100644 --- a/objects_test.go +++ b/objects_test.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "time" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" . "gopkg.in/check.v1" "io" @@ -17,7 +17,7 @@ type ObjectsSuite struct { var _ = Suite(&ObjectsSuite{}) func (s *ObjectsSuite) TestNewCommit(c *C) { - hash := core.NewHash("a5b8b09e2f8fcb0bb99d3ccb0958157b40890d69") + hash := plumbing.NewHash("a5b8b09e2f8fcb0bb99d3ccb0958157b40890d69") commit, err := s.Repository.Commit(hash) c.Assert(err, IsNil) @@ -45,7 +45,7 @@ func (s *ObjectsSuite) TestNewCommit(c *C) { } func (s *ObjectsSuite) TestParseTree(c *C) { - hash := core.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c") + hash := plumbing.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c") tree, err := s.Repository.Tree(hash) c.Assert(err, IsNil) @@ -3,9 +3,9 @@ package git import ( "errors" - "gopkg.in/src-d/go-git.v4/clients/common" "gopkg.in/src-d/go-git.v4/config" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/client/common" ) const ( @@ -27,7 +27,7 @@ type CloneOptions struct { // Name of the remote to be added, by default `origin` RemoteName string // Remote branch to clone - ReferenceName core.ReferenceName + ReferenceName plumbing.ReferenceName // Fetch only ReferenceName if true SingleBranch bool // Limit fetching to the specified number of commits @@ -45,7 +45,7 @@ func (o *CloneOptions) Validate() error { } if o.ReferenceName == "" { - o.ReferenceName = core.HEAD + o.ReferenceName = plumbing.HEAD } return nil @@ -56,7 +56,7 @@ type PullOptions struct { // Name of the remote to be pulled RemoteName string // Remote branch to clone - ReferenceName core.ReferenceName + ReferenceName plumbing.ReferenceName // Fetch only ReferenceName if true SingleBranch bool // Limit fetching to the specified number of commits @@ -70,7 +70,7 @@ func (o *PullOptions) Validate() error { } if o.ReferenceName == "" { - o.ReferenceName = core.HEAD + o.ReferenceName = plumbing.HEAD } return nil diff --git a/clients/common.go b/plumbing/client/common.go index c28c465..6a99339 100644 --- a/clients/common.go +++ b/plumbing/client/common.go @@ -16,9 +16,9 @@ package clients import ( "fmt" - "gopkg.in/src-d/go-git.v4/clients/common" - "gopkg.in/src-d/go-git.v4/clients/http" - "gopkg.in/src-d/go-git.v4/clients/ssh" + "gopkg.in/src-d/go-git.v4/plumbing/client/common" + "gopkg.in/src-d/go-git.v4/plumbing/client/http" + "gopkg.in/src-d/go-git.v4/plumbing/client/ssh" ) type GitUploadPackServiceFactory func(common.Endpoint) common.GitUploadPackService diff --git a/clients/common/common.go b/plumbing/client/common/common.go index c7cac00..97f78c4 100644 --- a/clients/common/common.go +++ b/plumbing/client/common/common.go @@ -11,10 +11,11 @@ import ( "regexp" "strings" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp" - "gopkg.in/src-d/go-git.v4/formats/packp/advrefs" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/advrefs" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing/storer" "gopkg.in/src-d/go-git.v4/storage/memory" ) @@ -52,11 +53,11 @@ func NewEndpoint(endpoint string) (Endpoint, error) { u, err := url.Parse(endpoint) if err != nil { - return Endpoint{}, core.NewPermanentError(err) + return Endpoint{}, plumbing.NewPermanentError(err) } if !u.IsAbs() { - return Endpoint{}, core.NewPermanentError(fmt.Errorf( + return Endpoint{}, plumbing.NewPermanentError(fmt.Errorf( "invalid endpoint: %s", endpoint, )) } @@ -95,15 +96,15 @@ func (i *GitUploadPackInfo) Decode(r io.Reader) error { ar := advrefs.New() if err := d.Decode(ar); err != nil { if err == advrefs.ErrEmpty { - return core.NewPermanentError(err) + return plumbing.NewPermanentError(err) } - return core.NewUnexpectedError(err) + return plumbing.NewUnexpectedError(err) } i.Capabilities = ar.Capabilities if err := i.addRefs(ar); err != nil { - return core.NewUnexpectedError(err) + return plumbing.NewUnexpectedError(err) } return nil @@ -111,7 +112,7 @@ func (i *GitUploadPackInfo) Decode(r io.Reader) error { func (i *GitUploadPackInfo) addRefs(ar *advrefs.AdvRefs) error { for name, hash := range ar.References { - ref := core.NewReferenceFromStrings(name, hash.String()) + ref := plumbing.NewReferenceFromStrings(name, hash.String()) i.Refs.SetReference(ref) } @@ -127,11 +128,11 @@ func (i *GitUploadPackInfo) addSymbolicRefs(ar *advrefs.AdvRefs) error { chunks := strings.Split(symref, ":") if len(chunks) != 2 { err := fmt.Errorf("bad number of `:` in symref value (%q)", symref) - return core.NewUnexpectedError(err) + return plumbing.NewUnexpectedError(err) } - name := core.ReferenceName(chunks[0]) - target := core.ReferenceName(chunks[1]) - ref := core.NewSymbolicReference(name, target) + name := plumbing.ReferenceName(chunks[0]) + target := plumbing.ReferenceName(chunks[1]) + ref := plumbing.NewSymbolicReference(name, target) i.Refs.SetReference(ref) } @@ -142,8 +143,8 @@ func hasSymrefs(ar *advrefs.AdvRefs) bool { return ar.Capabilities.Supports("symref") } -func (i *GitUploadPackInfo) Head() *core.Reference { - ref, _ := core.ResolveReference(i.Refs, core.HEAD) +func (i *GitUploadPackInfo) Head() *plumbing.Reference { + ref, _ := storer.ResolveReference(i.Refs, plumbing.HEAD) return ref } @@ -164,7 +165,7 @@ func (i *GitUploadPackInfo) Bytes() []byte { _ = e.Encodef("%s HEAD\x00%s\n", i.Head().Hash(), i.Capabilities.String()) for _, ref := range i.Refs { - if ref.Type() != core.HashReference { + if ref.Type() != plumbing.HashReference { continue } @@ -177,16 +178,16 @@ func (i *GitUploadPackInfo) Bytes() []byte { } type GitUploadPackRequest struct { - Wants []core.Hash - Haves []core.Hash + Wants []plumbing.Hash + Haves []plumbing.Hash Depth int } -func (r *GitUploadPackRequest) Want(h ...core.Hash) { +func (r *GitUploadPackRequest) Want(h ...plumbing.Hash) { r.Wants = append(r.Wants, h...) } -func (r *GitUploadPackRequest) Have(h ...core.Hash) { +func (r *GitUploadPackRequest) Have(h ...plumbing.Hash) { r.Haves = append(r.Haves, h...) } diff --git a/clients/common/common_test.go b/plumbing/client/common/common_test.go index 5809584..cf4d871 100644 --- a/clients/common/common_test.go +++ b/plumbing/client/common/common_test.go @@ -5,8 +5,8 @@ import ( "encoding/base64" "testing" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp" . "gopkg.in/check.v1" ) @@ -56,13 +56,13 @@ func (s *SuiteCommon) TestGitUploadPackInfo(c *C) { c.Assert(name, Equals, "refs/heads/master") c.Assert(i.Refs, HasLen, 4) - ref := i.Refs[core.ReferenceName(name)] + ref := i.Refs[plumbing.ReferenceName(name)] c.Assert(ref, NotNil) c.Assert(ref.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5") - ref = i.Refs[core.HEAD] + ref = i.Refs[plumbing.HEAD] c.Assert(ref, NotNil) - c.Assert(ref.Target(), Equals, core.ReferenceName(name)) + c.Assert(ref.Target(), Equals, plumbing.ReferenceName(name)) } const GitUploadPackInfoNoHEADFixture = "MDAxZSMgc2VydmljZT1naXQtdXBsb2FkLXBhY2sKMDAwMDAwYmNkN2UxZmVlMjYxMjM0YmIzYTQzYzA5NmY1NTg3NDhhNTY5ZDc5ZWZmIHJlZnMvaGVhZHMvdjQAbXVsdGlfYWNrIHRoaW4tcGFjayBzaWRlLWJhbmQgc2lkZS1iYW5kLTY0ayBvZnMtZGVsdGEgc2hhbGxvdyBuby1wcm9ncmVzcyBpbmNsdWRlLXRhZyBtdWx0aV9hY2tfZGV0YWlsZWQgbm8tZG9uZSBhZ2VudD1naXQvMS45LjEKMDAwMA==" @@ -95,11 +95,11 @@ func (s *SuiteCommon) TestGitUploadPackEncode(c *C) { info := NewGitUploadPackInfo() info.Capabilities.Add("symref", "HEAD:refs/heads/master") - ref := core.ReferenceName("refs/heads/master") - hash := core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") - info.Refs = map[core.ReferenceName]*core.Reference{ - core.HEAD: core.NewSymbolicReference(core.HEAD, ref), - ref: core.NewHashReference(ref, hash), + ref := plumbing.ReferenceName("refs/heads/master") + hash := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") + info.Refs = map[plumbing.ReferenceName]*plumbing.Reference{ + plumbing.HEAD: plumbing.NewSymbolicReference(plumbing.HEAD, ref), + ref: plumbing.NewHashReference(ref, hash), } c.Assert(info.Head(), NotNil) @@ -113,9 +113,9 @@ func (s *SuiteCommon) TestGitUploadPackEncode(c *C) { func (s *SuiteCommon) TestGitUploadPackRequest(c *C) { r := &GitUploadPackRequest{} - r.Want(core.NewHash("d82f291cde9987322c8a0c81a325e1ba6159684c")) - r.Want(core.NewHash("2b41ef280fdb67a9b250678686a0c3e03b0a9989")) - r.Have(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + r.Want(plumbing.NewHash("d82f291cde9987322c8a0c81a325e1ba6159684c")) + r.Want(plumbing.NewHash("2b41ef280fdb67a9b250678686a0c3e03b0a9989")) + r.Have(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) c.Assert(r.String(), Equals, "0032want d82f291cde9987322c8a0c81a325e1ba6159684c\n"+ diff --git a/clients/common_test.go b/plumbing/client/common_test.go index 59fc300..058c4d3 100644 --- a/clients/common_test.go +++ b/plumbing/client/common_test.go @@ -5,7 +5,7 @@ import ( "io" "testing" - "gopkg.in/src-d/go-git.v4/clients/common" + "gopkg.in/src-d/go-git.v4/plumbing/client/common" . "gopkg.in/check.v1" ) diff --git a/clients/http/common.go b/plumbing/client/http/common.go index 483308a..4c07876 100644 --- a/clients/http/common.go +++ b/plumbing/client/http/common.go @@ -5,8 +5,8 @@ import ( "fmt" "net/http" - "gopkg.in/src-d/go-git.v4/clients/common" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/client/common" ) // HTTPAuthMethod concrete implementation of common.AuthMethod for HTTP services @@ -62,7 +62,7 @@ func NewHTTPError(r *http.Response) error { } err := &HTTPError{r} - return core.NewUnexpectedError(err) + return plumbing.NewUnexpectedError(err) } // StatusCode returns the status code of the response diff --git a/clients/http/common_test.go b/plumbing/client/http/common_test.go index 287897d..287897d 100644 --- a/clients/http/common_test.go +++ b/plumbing/client/http/common_test.go diff --git a/clients/http/git_upload_pack.go b/plumbing/client/http/git_upload_pack.go index f652150..c1f4a0b 100644 --- a/clients/http/git_upload_pack.go +++ b/plumbing/client/http/git_upload_pack.go @@ -8,9 +8,9 @@ import ( "net/http" "strings" - "gopkg.in/src-d/go-git.v4/clients/common" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/client/common" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" ) // GitUploadPackService git-upoad-pack service over HTTP @@ -128,7 +128,7 @@ func (s *GitUploadPackService) doRequest(method, url string, content *strings.Re req, err := http.NewRequest(method, url, body) if err != nil { - return nil, core.NewPermanentError(err) + return nil, plumbing.NewPermanentError(err) } s.applyHeadersToRequest(req, content) @@ -136,7 +136,7 @@ func (s *GitUploadPackService) doRequest(method, url string, content *strings.Re res, err := s.client.Do(req) if err != nil { - return nil, core.NewUnexpectedError(err) + return nil, plumbing.NewUnexpectedError(err) } if err := NewHTTPError(res); err != nil { diff --git a/clients/http/git_upload_pack_test.go b/plumbing/client/http/git_upload_pack_test.go index 579419f..a50dbdf 100644 --- a/clients/http/git_upload_pack_test.go +++ b/plumbing/client/http/git_upload_pack_test.go @@ -4,8 +4,8 @@ import ( "io/ioutil" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/clients/common" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/client/common" ) type RemoteSuite struct { @@ -95,7 +95,7 @@ func (s *RemoteSuite) TestFetch(c *C) { c.Assert(r.Connect(), IsNil) req := &common.GitUploadPackRequest{} - req.Want(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + req.Want(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) reader, err := r.Fetch(req) c.Assert(err, IsNil) @@ -110,8 +110,8 @@ func (s *RemoteSuite) TestFetchNoChanges(c *C) { c.Assert(r.Connect(), IsNil) req := &common.GitUploadPackRequest{} - req.Want(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) - req.Have(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + req.Want(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + req.Have(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) reader, err := r.Fetch(req) c.Assert(err, Equals, common.ErrEmptyGitUploadPack) @@ -123,8 +123,8 @@ func (s *RemoteSuite) TestFetchMulti(c *C) { c.Assert(r.Connect(), IsNil) req := &common.GitUploadPackRequest{} - req.Want(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) - req.Want(core.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881")) + req.Want(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + req.Want(plumbing.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881")) reader, err := r.Fetch(req) c.Assert(err, IsNil) diff --git a/clients/ssh/auth_method.go b/plumbing/client/ssh/auth_method.go index 1ce45ef..587f59a 100644 --- a/clients/ssh/auth_method.go +++ b/plumbing/client/ssh/auth_method.go @@ -7,7 +7,7 @@ import ( "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" - "gopkg.in/src-d/go-git.v4/clients/common" + "gopkg.in/src-d/go-git.v4/plumbing/client/common" ) // AuthMethod is the interface all auth methods for the ssh client diff --git a/clients/ssh/auth_method_test.go b/plumbing/client/ssh/auth_method_test.go index a87c950..a87c950 100644 --- a/clients/ssh/auth_method_test.go +++ b/plumbing/client/ssh/auth_method_test.go diff --git a/clients/ssh/git_upload_pack.go b/plumbing/client/ssh/git_upload_pack.go index d53dc63..e2b73fd 100644 --- a/clients/ssh/git_upload_pack.go +++ b/plumbing/client/ssh/git_upload_pack.go @@ -8,10 +8,10 @@ import ( "io" "strings" - "gopkg.in/src-d/go-git.v4/clients/common" - "gopkg.in/src-d/go-git.v4/formats/packp/advrefs" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" - "gopkg.in/src-d/go-git.v4/formats/packp/ulreq" + "gopkg.in/src-d/go-git.v4/plumbing/client/common" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/advrefs" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/ulreq" "golang.org/x/crypto/ssh" ) diff --git a/clients/ssh/git_upload_pack_test.go b/plumbing/client/ssh/git_upload_pack_test.go index d7160dc..4d5b2b1 100644 --- a/clients/ssh/git_upload_pack_test.go +++ b/plumbing/client/ssh/git_upload_pack_test.go @@ -5,8 +5,8 @@ import ( "os" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/clients/common" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/client/common" ) type RemoteSuite struct { @@ -106,7 +106,7 @@ func (s *RemoteSuite) TestCapabilities(c *C) { func (s *RemoteSuite) TestFetchNotConnected(c *C) { r := NewGitUploadPackService(s.Endpoint) pr := &common.GitUploadPackRequest{} - pr.Want(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + pr.Want(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) _, err := r.Fetch(pr) c.Assert(err, Equals, ErrNotConnected) } @@ -117,8 +117,8 @@ func (s *RemoteSuite) TestFetch(c *C) { defer func() { c.Assert(r.Disconnect(), IsNil) }() req := &common.GitUploadPackRequest{} - req.Want(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) - req.Want(core.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881")) + req.Want(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + req.Want(plumbing.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881")) reader, err := r.Fetch(req) c.Assert(err, IsNil) defer func() { c.Assert(reader.Close(), IsNil) }() @@ -134,7 +134,7 @@ func (s *RemoteSuite) TestFetchError(c *C) { defer func() { c.Assert(r.Disconnect(), IsNil) }() req := &common.GitUploadPackRequest{} - req.Want(core.NewHash("1111111111111111111111111111111111111111")) + req.Want(plumbing.NewHash("1111111111111111111111111111111111111111")) reader, err := r.Fetch(req) c.Assert(err, IsNil) diff --git a/core/errors.go b/plumbing/errors.go index 50772b6..a3ebed3 100644 --- a/core/errors.go +++ b/plumbing/errors.go @@ -1,4 +1,4 @@ -package core +package plumbing import "fmt" diff --git a/formats/config/common.go b/plumbing/format/config/common.go index d2f1e5c..d2f1e5c 100644 --- a/formats/config/common.go +++ b/plumbing/format/config/common.go diff --git a/formats/config/common_test.go b/plumbing/format/config/common_test.go index 365b53f..365b53f 100644 --- a/formats/config/common_test.go +++ b/plumbing/format/config/common_test.go diff --git a/formats/config/decoder.go b/plumbing/format/config/decoder.go index 0f02ce1..0f02ce1 100644 --- a/formats/config/decoder.go +++ b/plumbing/format/config/decoder.go diff --git a/formats/config/decoder_test.go b/plumbing/format/config/decoder_test.go index 412549f..412549f 100644 --- a/formats/config/decoder_test.go +++ b/plumbing/format/config/decoder_test.go diff --git a/formats/config/doc.go b/plumbing/format/config/doc.go index dd77fbc..dd77fbc 100644 --- a/formats/config/doc.go +++ b/plumbing/format/config/doc.go diff --git a/formats/config/encoder.go b/plumbing/format/config/encoder.go index 88bdf65..88bdf65 100644 --- a/formats/config/encoder.go +++ b/plumbing/format/config/encoder.go diff --git a/formats/config/encoder_test.go b/plumbing/format/config/encoder_test.go index 5335b83..5335b83 100644 --- a/formats/config/encoder_test.go +++ b/plumbing/format/config/encoder_test.go diff --git a/formats/config/fixtures_test.go b/plumbing/format/config/fixtures_test.go index 12ff288..12ff288 100644 --- a/formats/config/fixtures_test.go +++ b/plumbing/format/config/fixtures_test.go diff --git a/formats/config/option.go b/plumbing/format/config/option.go index dbb401c..dbb401c 100644 --- a/formats/config/option.go +++ b/plumbing/format/config/option.go diff --git a/formats/config/option_test.go b/plumbing/format/config/option_test.go index 8588de1..8588de1 100644 --- a/formats/config/option_test.go +++ b/plumbing/format/config/option_test.go diff --git a/formats/config/section.go b/plumbing/format/config/section.go index 1844913..1844913 100644 --- a/formats/config/section.go +++ b/plumbing/format/config/section.go diff --git a/formats/config/section_test.go b/plumbing/format/config/section_test.go index cfd9f3f..cfd9f3f 100644 --- a/formats/config/section_test.go +++ b/plumbing/format/config/section_test.go diff --git a/formats/idxfile/decoder.go b/plumbing/format/idxfile/decoder.go index 884d32b..e3ffc4b 100644 --- a/formats/idxfile/decoder.go +++ b/plumbing/format/idxfile/decoder.go @@ -5,7 +5,7 @@ import ( "errors" "io" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/utils/binary" ) @@ -99,7 +99,7 @@ func readFanout(idx *Idxfile, r io.Reader) error { func readObjectNames(idx *Idxfile, r io.Reader) error { c := int(idx.ObjectCount) for i := 0; i < c; i++ { - var ref core.Hash + var ref plumbing.Hash if _, err := r.Read(ref[:]); err != nil { return err } diff --git a/formats/idxfile/decoder_test.go b/plumbing/format/idxfile/decoder_test.go index 18546d2..5231e64 100644 --- a/formats/idxfile/decoder_test.go +++ b/plumbing/format/idxfile/decoder_test.go @@ -7,7 +7,7 @@ import ( . "gopkg.in/check.v1" "gopkg.in/src-d/go-git.v4/fixtures" - "gopkg.in/src-d/go-git.v4/formats/packfile" + "gopkg.in/src-d/go-git.v4/plumbing/format/packfile" "gopkg.in/src-d/go-git.v4/storage/memory" ) diff --git a/formats/idxfile/doc.go b/plumbing/format/idxfile/doc.go index 8a76853..8a76853 100644 --- a/formats/idxfile/doc.go +++ b/plumbing/format/idxfile/doc.go diff --git a/formats/idxfile/encoder.go b/plumbing/format/idxfile/encoder.go index 164414a..164414a 100644 --- a/formats/idxfile/encoder.go +++ b/plumbing/format/idxfile/encoder.go diff --git a/formats/idxfile/encoder_test.go b/plumbing/format/idxfile/encoder_test.go index d9d83eb..9a53863 100644 --- a/formats/idxfile/encoder_test.go +++ b/plumbing/format/idxfile/encoder_test.go @@ -5,14 +5,14 @@ import ( "io/ioutil" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" + "gopkg.in/src-d/go-git.v4/plumbing" ) func (s *IdxfileSuite) TestEncode(c *C) { expected := &Idxfile{} - expected.Add(core.NewHash("4bfc730165c370df4a012afbb45ba3f9c332c0d4"), 82, 82) - expected.Add(core.NewHash("8fa2238efdae08d83c12ee176fae65ff7c99af46"), 42, 42) + expected.Add(plumbing.NewHash("4bfc730165c370df4a012afbb45ba3f9c332c0d4"), 82, 82) + expected.Add(plumbing.NewHash("8fa2238efdae08d83c12ee176fae65ff7c99af46"), 42, 42) buf := bytes.NewBuffer(nil) e := NewEncoder(buf) diff --git a/formats/idxfile/idxfile.go b/plumbing/format/idxfile/idxfile.go index 8549d3f..8329c23 100644 --- a/formats/idxfile/idxfile.go +++ b/plumbing/format/idxfile/idxfile.go @@ -1,6 +1,6 @@ package idxfile -import "gopkg.in/src-d/go-git.v4/core" +import "gopkg.in/src-d/go-git.v4/plumbing" const ( // VersionSupported is the only idx version supported. @@ -24,12 +24,12 @@ type Idxfile struct { // An Entry represents data about an object in the packfile: its hash, // offset and CRC32 checksum. type Entry struct { - Hash core.Hash + Hash plumbing.Hash CRC32 uint32 Offset uint64 } -func (idx *Idxfile) Add(h core.Hash, offset uint64, crc32 uint32) { +func (idx *Idxfile) Add(h plumbing.Hash, offset uint64, crc32 uint32) { idx.Entries = append(idx.Entries, Entry{ Hash: h, Offset: offset, diff --git a/formats/index/decoder.go b/plumbing/format/index/decoder.go index f3d4343..9069c9e 100644 --- a/formats/index/decoder.go +++ b/plumbing/format/index/decoder.go @@ -10,7 +10,7 @@ import ( "strconv" "time" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/utils/binary" ) @@ -273,7 +273,7 @@ func (d *Decoder) getExtensionReader() (io.Reader, error) { } func (d *Decoder) readChecksum(expected []byte, alreadyRead [4]byte) error { - var h core.Hash + var h plumbing.Hash copy(h[:4], alreadyRead[:]) if err := binary.Read(d.r, h[4:]); err != nil { @@ -399,7 +399,7 @@ func (d *resolveUndoDecoder) Decode(ru *ResolveUndo) error { func (d *resolveUndoDecoder) readEntry() (*ResolveUndoEntry, error) { e := &ResolveUndoEntry{ - Stages: make(map[Stage]core.Hash, 0), + Stages: make(map[Stage]plumbing.Hash, 0), } path, err := binary.ReadUntil(d.r, '\x00') @@ -416,7 +416,7 @@ func (d *resolveUndoDecoder) readEntry() (*ResolveUndoEntry, error) { } for s := range e.Stages { - var hash core.Hash + var hash plumbing.Hash if err := binary.Read(d.r, hash[:]); err != nil { return nil, err } @@ -439,7 +439,7 @@ func (d *resolveUndoDecoder) readStage(e *ResolveUndoEntry, s Stage) error { } if stage != 0 { - e.Stages[s] = core.ZeroHash + e.Stages[s] = plumbing.ZeroHash } return nil diff --git a/formats/index/decoder_test.go b/plumbing/format/index/decoder_test.go index a05417d..44ecb69 100644 --- a/formats/index/decoder_test.go +++ b/plumbing/format/index/decoder_test.go @@ -4,8 +4,8 @@ import ( "testing" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" + "gopkg.in/src-d/go-git.v4/plumbing" ) func Test(t *testing.T) { TestingT(t) } @@ -80,11 +80,11 @@ func (s *IdxfileSuite) TestDecodeCacheTree(c *C) { } var expectedEntries = []TreeEntry{ - {Path: "", Entries: 9, Trees: 4, Hash: core.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")}, - {Path: "go", Entries: 1, Trees: 0, Hash: core.NewHash("a39771a7651f97faf5c72e08224d857fc35133db")}, - {Path: "php", Entries: 1, Trees: 0, Hash: core.NewHash("586af567d0bb5e771e49bdd9434f5e0fb76d25fa")}, - {Path: "json", Entries: 2, Trees: 0, Hash: core.NewHash("5a877e6a906a2743ad6e45d99c1793642aaf8eda")}, - {Path: "vendor", Entries: 1, Trees: 0, Hash: core.NewHash("cf4aa3b38974fb7d81f367c0830f7d78d65ab86b")}, + {Path: "", Entries: 9, Trees: 4, Hash: plumbing.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")}, + {Path: "go", Entries: 1, Trees: 0, Hash: plumbing.NewHash("a39771a7651f97faf5c72e08224d857fc35133db")}, + {Path: "php", Entries: 1, Trees: 0, Hash: plumbing.NewHash("586af567d0bb5e771e49bdd9434f5e0fb76d25fa")}, + {Path: "json", Entries: 2, Trees: 0, Hash: plumbing.NewHash("5a877e6a906a2743ad6e45d99c1793642aaf8eda")}, + {Path: "vendor", Entries: 1, Trees: 0, Hash: plumbing.NewHash("cf4aa3b38974fb7d81f367c0830f7d78d65ab86b")}, } func (s *IdxfileSuite) TestDecodeMergeConflict(c *C) { @@ -159,13 +159,13 @@ func (s *IdxfileSuite) TestDecodeResolveUndo(c *C) { c.Assert(ru.Entries, HasLen, 2) c.Assert(ru.Entries[0].Path, Equals, "go/example.go") c.Assert(ru.Entries[0].Stages, HasLen, 3) - c.Assert(ru.Entries[0].Stages[AncestorMode], Not(Equals), core.ZeroHash) - c.Assert(ru.Entries[0].Stages[OurMode], Not(Equals), core.ZeroHash) - c.Assert(ru.Entries[0].Stages[TheirMode], Not(Equals), core.ZeroHash) + c.Assert(ru.Entries[0].Stages[AncestorMode], Not(Equals), plumbing.ZeroHash) + c.Assert(ru.Entries[0].Stages[OurMode], Not(Equals), plumbing.ZeroHash) + c.Assert(ru.Entries[0].Stages[TheirMode], Not(Equals), plumbing.ZeroHash) c.Assert(ru.Entries[1].Path, Equals, "haskal/haskal.hs") c.Assert(ru.Entries[1].Stages, HasLen, 2) - c.Assert(ru.Entries[1].Stages[OurMode], Not(Equals), core.ZeroHash) - c.Assert(ru.Entries[1].Stages[TheirMode], Not(Equals), core.ZeroHash) + c.Assert(ru.Entries[1].Stages[OurMode], Not(Equals), plumbing.ZeroHash) + c.Assert(ru.Entries[1].Stages[TheirMode], Not(Equals), plumbing.ZeroHash) } func (s *IdxfileSuite) TestDecodeV4(c *C) { diff --git a/formats/index/doc.go b/plumbing/format/index/doc.go index 00466af..3a72606 100644 --- a/formats/index/doc.go +++ b/plumbing/format/index/doc.go @@ -253,14 +253,14 @@ Git index format - Stat data of $GIT_DIR/info/exclude. See "Index entry" section from ctime field until "file size". - - Stat data of core.excludesfile + - Stat data of plumbing.excludesfile - 32-bit dir_flags (see struct dir_struct) - 160-bit SHA-1 of $GIT_DIR/info/exclude. Null SHA-1 means the file does not exist. - - 160-bit SHA-1 of core.excludesfile. Null SHA-1 means the file does + - 160-bit SHA-1 of plumbing.excludesfile. Null SHA-1 means the file does not exist. - NUL-terminated string of per-dir exclude file name. This usually diff --git a/formats/index/encoder.go b/plumbing/format/index/encoder.go index 94fbc68..94fbc68 100644 --- a/formats/index/encoder.go +++ b/plumbing/format/index/encoder.go diff --git a/formats/index/encoder_test.go b/plumbing/format/index/encoder_test.go index 3085988..6770985 100644 --- a/formats/index/encoder_test.go +++ b/plumbing/format/index/encoder_test.go @@ -6,7 +6,7 @@ import ( "time" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) func (s *IdxfileSuite) TestEncode(c *C) { @@ -21,7 +21,7 @@ func (s *IdxfileSuite) TestEncode(c *C) { GID: 8484, Size: 42, Stage: TheirMode, - Hash: core.NewHash("e25b29c8946e0e192fae2edc1dabf7be71e8ecf3"), + Hash: plumbing.NewHash("e25b29c8946e0e192fae2edc1dabf7be71e8ecf3"), Name: "foo", }, { CreatedAt: time.Now(), diff --git a/formats/index/index.go b/plumbing/format/index/index.go index 35a5391..4a3c798 100644 --- a/formats/index/index.go +++ b/plumbing/format/index/index.go @@ -5,7 +5,7 @@ import ( "os" "time" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) var ( @@ -47,7 +47,7 @@ type Index struct { // multiple Entry instances may appear for the same path name. type Entry struct { // Hash is the SHA1 of the represented file - Hash core.Hash + Hash plumbing.Hash // Name is the Entry path name relative to top level directory Name string // CreatedAt time when the tracked path was created @@ -90,7 +90,7 @@ type TreeEntry struct { Trees int // Hash object name for the object that would result from writing this span // of index as a tree. - Hash core.Hash + Hash plumbing.Hash } // ResolveUndo when a conflict is resolved (e.g. with "git add path"), these @@ -104,5 +104,5 @@ type ResolveUndo struct { // ResolveUndoEntry contains the information about a conflict when is resolved type ResolveUndoEntry struct { Path string - Stages map[Stage]core.Hash + Stages map[Stage]plumbing.Hash } diff --git a/formats/objfile/common_test.go b/plumbing/format/objfile/common_test.go index 682dfbb..7c8b75c 100644 --- a/formats/objfile/common_test.go +++ b/plumbing/format/objfile/common_test.go @@ -5,62 +5,62 @@ import ( "testing" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) type objfileFixture struct { - hash string // hash of data - t core.ObjectType // object type - content string // base64-encoded content - data string // base64-encoded objfile data + hash string // hash of data + t plumbing.ObjectType // object type + content string // base64-encoded content + data string // base64-encoded objfile data } var objfileFixtures = []objfileFixture{ { "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", - core.BlobObject, + plumbing.BlobObject, base64.StdEncoding.EncodeToString([]byte("")), "eAFLyslPUjBgAAAJsAHw", }, { "a8a940627d132695a9769df883f85992f0ff4a43", - core.BlobObject, + plumbing.BlobObject, base64.StdEncoding.EncodeToString([]byte("this is a test")), "eAFLyslPUjA0YSjJyCxWAKJEhZLU4hIAUDYHOg==", }, { "4dc2174801ac4a3d36886210fd086fbe134cf7b2", - core.BlobObject, + plumbing.BlobObject, base64.StdEncoding.EncodeToString([]byte("this\nis\n\n\na\nmultiline\n\ntest.\n")), "eAFLyslPUjCyZCjJyCzmAiIurkSu3NKcksyczLxULq6S1OISPS4A1I8LMQ==", }, { "13e6f47dd57798bfdc728d91f5c6d7f40c5bb5fc", - core.BlobObject, + plumbing.BlobObject, base64.StdEncoding.EncodeToString([]byte("this tests\r\nCRLF\r\nencoded files.\r\n")), "eAFLyslPUjA2YSjJyCxWKEktLinm5XIO8nHj5UrNS85PSU1RSMvMSS3W4+UCABp3DNE=", }, { "72a7bc4667ab068e954172437b993d9fbaa137cb", - core.BlobObject, + plumbing.BlobObject, base64.StdEncoding.EncodeToString([]byte("test@example.com")), "eAFLyslPUjA0YyhJLS5xSK1IzC3ISdVLzs8FAGVtCIA=", }, { "bb2b40e85ec0455d1de72daff71583f0dd72a33f", - core.BlobObject, + plumbing.BlobObject, base64.StdEncoding.EncodeToString([]byte("package main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n\r\n\t\"gopkg.in/src-d/go-git.v3\"\r\n)\r\n\r\nfunc main() {\r\n\tfmt.Printf(\"Retrieving %q ...\\n\", os.Args[2])\r\n\tr, err := git.NewRepository(os.Args[2], nil)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\r\n\tif err := r.Pull(\"origin\", \"refs/heads/master\"); err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\r\n\tdumpCommits(r)\r\n}\r\n\r\nfunc dumpCommits(r *git.Repository) {\r\n\titer := r.Commits()\r\n\tdefer iter.Close()\r\n\r\n\tfor {\r\n\t\tcommit, err := iter.Next()\r\n\t\tif err != nil {\r\n\t\t\tif err == io.EOF {\r\n\t\t\t\tbreak\r\n\t\t\t}\r\n\r\n\t\t\tpanic(err)\r\n\t\t}\r\n\r\n\t\tfmt.Println(commit)\r\n\t}\r\n}\r\n")), "eAGNUU1LAzEU9JpC/0NcEFJps2ARQdmDFD3W0qt6SHez8dHdZH1JqyL+d/Oy/aDgQVh47LzJTGayatyKX99MzzpVrpXRvFVgh4PhANrOYeBiOGBZ3YaMJrg0nI+D/o3r1kaCzT2Wkyo3bmIgyO00rkfEqDe2TIJixL/jgagjFwg21CJb6oCgt2ANv3jnUsoXm4258/IejX++eo0CDMdcI/LbgpPuXH8sdec8BIdf4sgccwsN0aFO9POCgGTIOmWhFFGE9j/p1jtWFEW52DSNyByCAXLPUNc+f9Oq8nmrfNCYje7+o1lt2m7m2haCF2SVnFL6kw2/pBzHEH0rEH0oI8q9BF220nWEaSdnjfNaRDDCtcM+WZnsDgUl4lx/BuKxv6rYY0XBwcmHp8deh7EVarWmQ7uC2Glre/TweI0VvTk5xaTx+wWX66Gs", }, { "e94db0f9ffca44dc7bade6a3591f544183395a7c", - core.TreeObject, + plumbing.TreeObject, "MTAwNjQ0IFRlc3QgMS50eHQAqKlAYn0TJpWpdp34g/hZkvD/SkMxMDA2NDQgVGVzdCAyLnR4dABNwhdIAaxKPTaIYhD9CG++E0z3sjEwMDY0NCBUZXN0IDMudHh0ABPm9H3Vd5i/3HKNkfXG1/QMW7X8MTAwNjQ0IFRlc3QgNC50eHQAcqe8RmerBo6VQXJDe5k9n7qhN8sxMDA2NDQgVGVzdCA1LnR4dAC7K0DoXsBFXR3nLa/3FYPw3XKjPw==", "eAErKUpNVTC0NGAwNDAwMzFRCEktLlEw1CupKGFYsdIhqVZYberKsrk/mn9ETvrw38sZWZURWJXvIXEPxjVetmYdSQJ/OfL3Cft834SsyhisSvjZl9qr5TP23ynqnfj12PUvPNFb/yCrMgGrKlq+xy19NVvfVMci5+qZtvN3LTQ/jazKFKxqt7bDi7gDrrGyz3XXfxdt/nC3aLE9AA2STmk=", }, { "9d7f8a56eaf92469dee8a856e716a03387ddb076", - core.CommitObject, + plumbing.CommitObject, "dHJlZSBlOTRkYjBmOWZmY2E0NGRjN2JhZGU2YTM1OTFmNTQ0MTgzMzk1YTdjCmF1dGhvciBKb3NodWEgU2pvZGluZyA8am9zaHVhLnNqb2RpbmdAc2NqYWxsaWFuY2UuY29tPiAxNDU2NTMxNTgzIC0wODAwCmNvbW1pdHRlciBKb3NodWEgU2pvZGluZyA8am9zaHVhLnNqb2RpbmdAc2NqYWxsaWFuY2UuY29tPiAxNDU2NTMxNTgzIC0wODAwCgpUZXN0IENvbW1pdAo=", "eAGtjksOgjAUAF33FO8CktZ+aBNjTNy51Qs8Xl8FAjSh5f4SvILLmcVkKM/zUOEi3amuzMDBxE6mkBKhMZHaDiM71DaoZI1RXutgsSWBW+3zCs9c+g3hNeY4LB+4jgc35cf3QiNO04ALcUN5voEy1lmtrNdwll5Ksdt9oPIfUuLNpcLjCIov3ApFmQ==", }, diff --git a/formats/objfile/reader.go b/plumbing/format/objfile/reader.go index 5c319f6..e7e119c 100644 --- a/formats/objfile/reader.go +++ b/plumbing/format/objfile/reader.go @@ -6,8 +6,8 @@ import ( "io" "strconv" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packfile" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packfile" ) var ( @@ -22,7 +22,7 @@ var ( type Reader struct { multi io.Reader zlib io.ReadCloser - hasher core.Hasher + hasher plumbing.Hasher } // NewReader returns a new Reader reading from r. @@ -38,14 +38,14 @@ func NewReader(r io.Reader) (*Reader, error) { } // Header reads the type and the size of object, and prepares the reader for read -func (r *Reader) Header() (t core.ObjectType, size int64, err error) { +func (r *Reader) Header() (t plumbing.ObjectType, size int64, err error) { var raw []byte raw, err = r.readUntil(' ') if err != nil { return } - t, err = core.ParseObjectType(string(raw)) + t, err = plumbing.ParseObjectType(string(raw)) if err != nil { return } @@ -86,8 +86,8 @@ func (r *Reader) readUntil(delim byte) ([]byte, error) { } } -func (r *Reader) prepareForRead(t core.ObjectType, size int64) { - r.hasher = core.NewHasher(t, size) +func (r *Reader) prepareForRead(t plumbing.ObjectType, size int64) { + r.hasher = plumbing.NewHasher(t, size) r.multi = io.TeeReader(r.zlib, r.hasher) } @@ -103,7 +103,7 @@ func (r *Reader) Read(p []byte) (n int, err error) { } // Hash returns the hash of the object data stream that has been read so far. -func (r *Reader) Hash() core.Hash { +func (r *Reader) Hash() plumbing.Hash { return r.hasher.Sum() } diff --git a/formats/objfile/reader_test.go b/plumbing/format/objfile/reader_test.go index a383fd2..715792d 100644 --- a/formats/objfile/reader_test.go +++ b/plumbing/format/objfile/reader_test.go @@ -8,7 +8,7 @@ import ( "io/ioutil" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) type SuiteReader struct{} @@ -18,7 +18,7 @@ var _ = Suite(&SuiteReader{}) func (s *SuiteReader) TestReadObjfile(c *C) { for k, fixture := range objfileFixtures { com := fmt.Sprintf("test %d: ", k) - hash := core.NewHash(fixture.hash) + hash := plumbing.NewHash(fixture.hash) content, _ := base64.StdEncoding.DecodeString(fixture.content) data, _ := base64.StdEncoding.DecodeString(fixture.data) @@ -26,7 +26,7 @@ func (s *SuiteReader) TestReadObjfile(c *C) { } } -func testReader(c *C, source io.Reader, hash core.Hash, t core.ObjectType, content []byte, com string) { +func testReader(c *C, source io.Reader, hash plumbing.Hash, t plumbing.ObjectType, content []byte, com string) { r, err := NewReader(source) c.Assert(err, IsNil) diff --git a/formats/objfile/writer.go b/plumbing/format/objfile/writer.go index d2f2314..44563d2 100644 --- a/formats/objfile/writer.go +++ b/plumbing/format/objfile/writer.go @@ -6,7 +6,7 @@ import ( "io" "strconv" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) var ( @@ -19,7 +19,7 @@ var ( type Writer struct { raw io.Writer zlib io.WriteCloser - hasher core.Hasher + hasher plumbing.Hasher multi io.Writer closed bool @@ -38,11 +38,11 @@ func NewWriter(w io.Writer) *Writer { } // WriteHeader writes the type and the size and prepares to accept the object's -// contents. If an invalid t is provided, core.ErrInvalidType is returned. If a +// contents. If an invalid t is provided, plumbing.ErrInvalidType is returned. If a // negative size is provided, ErrNegativeSize is returned. -func (w *Writer) WriteHeader(t core.ObjectType, size int64) error { +func (w *Writer) WriteHeader(t plumbing.ObjectType, size int64) error { if !t.Valid() { - return core.ErrInvalidType + return plumbing.ErrInvalidType } if size < 0 { return ErrNegativeSize @@ -59,10 +59,10 @@ func (w *Writer) WriteHeader(t core.ObjectType, size int64) error { return err } -func (w *Writer) prepareForWrite(t core.ObjectType, size int64) { +func (w *Writer) prepareForWrite(t plumbing.ObjectType, size int64) { w.pending = size - w.hasher = core.NewHasher(t, size) + w.hasher = plumbing.NewHasher(t, size) w.multi = io.MultiWriter(w.zlib, w.hasher) } @@ -91,7 +91,7 @@ func (w *Writer) Write(p []byte) (n int, err error) { // Hash returns the hash of the object data stream that has been written so far. // It can be called before or after Close. -func (w *Writer) Hash() core.Hash { +func (w *Writer) Hash() plumbing.Hash { return w.hasher.Sum() // Not yet closed, return hash of data written so far } diff --git a/formats/objfile/writer_test.go b/plumbing/format/objfile/writer_test.go index 18bba79..46dbea6 100644 --- a/formats/objfile/writer_test.go +++ b/plumbing/format/objfile/writer_test.go @@ -7,7 +7,7 @@ import ( "io" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) type SuiteWriter struct{} @@ -19,7 +19,7 @@ func (s *SuiteWriter) TestWriteObjfile(c *C) { buffer := bytes.NewBuffer(nil) com := fmt.Sprintf("test %d: ", k) - hash := core.NewHash(fixture.hash) + hash := plumbing.NewHash(fixture.hash) content, _ := base64.StdEncoding.DecodeString(fixture.content) // Write the data out to the buffer @@ -30,7 +30,7 @@ func (s *SuiteWriter) TestWriteObjfile(c *C) { } } -func testWriter(c *C, dest io.Writer, hash core.Hash, t core.ObjectType, content []byte) { +func testWriter(c *C, dest io.Writer, hash plumbing.Hash, t plumbing.ObjectType, content []byte) { size := int64(len(content)) w := NewWriter(dest) @@ -49,7 +49,7 @@ func (s *SuiteWriter) TestWriteOverflow(c *C) { buf := bytes.NewBuffer(nil) w := NewWriter(buf) - err := w.WriteHeader(core.BlobObject, 8) + err := w.WriteHeader(plumbing.BlobObject, 8) c.Assert(err, IsNil) n, err := w.Write([]byte("1234")) @@ -65,16 +65,16 @@ func (s *SuiteWriter) TestNewWriterInvalidType(c *C) { buf := bytes.NewBuffer(nil) w := NewWriter(buf) - err := w.WriteHeader(core.InvalidObject, 8) - c.Assert(err, Equals, core.ErrInvalidType) + err := w.WriteHeader(plumbing.InvalidObject, 8) + c.Assert(err, Equals, plumbing.ErrInvalidType) } func (s *SuiteWriter) TestNewWriterInvalidSize(c *C) { buf := bytes.NewBuffer(nil) w := NewWriter(buf) - err := w.WriteHeader(core.BlobObject, -1) + err := w.WriteHeader(plumbing.BlobObject, -1) c.Assert(err, Equals, ErrNegativeSize) - err = w.WriteHeader(core.BlobObject, -1651860) + err = w.WriteHeader(plumbing.BlobObject, -1651860) c.Assert(err, Equals, ErrNegativeSize) } diff --git a/formats/packfile/decoder.go b/plumbing/format/packfile/decoder.go index e96980a..470e59b 100644 --- a/formats/packfile/decoder.go +++ b/plumbing/format/packfile/decoder.go @@ -3,7 +3,8 @@ package packfile import ( "bytes" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" ) // Format specifies if the packfile uses ref-deltas or ofs-deltas. @@ -34,7 +35,7 @@ var ( // to recall cannot be returned. ErrCannotRecall = NewError("cannot recall object") // ErrNonSeekable is returned if a NewDecoder is used with a non-seekable - // reader and without a core.ObjectStorage or ReadObjectAt method is called + // reader and without a plumbing.ObjectStorage or ReadObjectAt method is called // without a seekable scanner ErrNonSeekable = NewError("non-seekable scanner") // ErrRollback error making Rollback over a transaction after an error @@ -44,16 +45,16 @@ var ( // Decoder reads and decodes packfiles from an input stream. type Decoder struct { s *Scanner - o core.ObjectStorer - tx core.Transaction + o storer.ObjectStorer + tx storer.Transaction - offsetToHash map[int64]core.Hash - hashToOffset map[core.Hash]int64 - crcs map[core.Hash]uint32 + offsetToHash map[int64]plumbing.Hash + hashToOffset map[plumbing.Hash]int64 + crcs map[plumbing.Hash]uint32 } // NewDecoder returns a new Decoder that reads from r. -func NewDecoder(s *Scanner, o core.ObjectStorer) (*Decoder, error) { +func NewDecoder(s *Scanner, o storer.ObjectStorer) (*Decoder, error) { if !s.IsSeekable && o == nil { return nil, ErrNonSeekable } @@ -62,16 +63,16 @@ func NewDecoder(s *Scanner, o core.ObjectStorer) (*Decoder, error) { s: s, o: o, - offsetToHash: make(map[int64]core.Hash, 0), - hashToOffset: make(map[core.Hash]int64, 0), - crcs: make(map[core.Hash]uint32, 0), + offsetToHash: make(map[int64]plumbing.Hash, 0), + hashToOffset: make(map[plumbing.Hash]int64, 0), + crcs: make(map[plumbing.Hash]uint32, 0), }, nil } // Decode reads a packfile and stores it in the value pointed to by s. -func (d *Decoder) Decode() (checksum core.Hash, err error) { +func (d *Decoder) Decode() (checksum plumbing.Hash, err error) { if err := d.doDecode(); err != nil { - return core.ZeroHash, err + return plumbing.ZeroHash, err } return d.s.Checksum() @@ -83,7 +84,7 @@ func (d *Decoder) doDecode() error { return err } - _, isTxStorer := d.o.(core.Transactioner) + _, isTxStorer := d.o.(storer.Transactioner) switch { case d.o == nil: return d.readObjects(int(count)) @@ -120,7 +121,7 @@ func (d *Decoder) readObjectsWithObjectStorer(count int) error { } func (d *Decoder) readObjectsWithObjectStorerTx(count int) error { - tx := d.o.(core.Transactioner).Begin() + tx := d.o.(storer.Transactioner).Begin() for i := 0; i < count; i++ { obj, err := d.ReadObject() @@ -144,7 +145,7 @@ func (d *Decoder) readObjectsWithObjectStorerTx(count int) error { } // ReadObject reads a object from the stream and return it -func (d *Decoder) ReadObject() (core.Object, error) { +func (d *Decoder) ReadObject() (plumbing.Object, error) { h, err := d.s.NextObjectHeader() if err != nil { return nil, err @@ -155,11 +156,11 @@ func (d *Decoder) ReadObject() (core.Object, error) { obj.SetType(h.Type) var crc uint32 switch h.Type { - case core.CommitObject, core.TreeObject, core.BlobObject, core.TagObject: + case plumbing.CommitObject, plumbing.TreeObject, plumbing.BlobObject, plumbing.TagObject: crc, err = d.fillRegularObjectContent(obj) - case core.REFDeltaObject: + case plumbing.REFDeltaObject: crc, err = d.fillREFDeltaObjectContent(obj, h.Reference) - case core.OFSDeltaObject: + case plumbing.OFSDeltaObject: crc, err = d.fillOFSDeltaObjectContent(obj, h.OffsetReference) default: err = ErrInvalidObject.AddDetails("type %q", h.Type) @@ -176,16 +177,16 @@ func (d *Decoder) ReadObject() (core.Object, error) { return obj, nil } -func (d *Decoder) newObject() core.Object { +func (d *Decoder) newObject() plumbing.Object { if d.o == nil { - return &core.MemoryObject{} + return &plumbing.MemoryObject{} } return d.o.NewObject() } // ReadObjectAt reads an object at the given location -func (d *Decoder) ReadObjectAt(offset int64) (core.Object, error) { +func (d *Decoder) ReadObjectAt(offset int64) (plumbing.Object, error) { if !d.s.IsSeekable { return nil, ErrNonSeekable } @@ -205,7 +206,7 @@ func (d *Decoder) ReadObjectAt(offset int64) (core.Object, error) { return d.ReadObject() } -func (d *Decoder) fillRegularObjectContent(obj core.Object) (uint32, error) { +func (d *Decoder) fillRegularObjectContent(obj plumbing.Object) (uint32, error) { w, err := obj.Writer() if err != nil { return 0, err @@ -215,7 +216,7 @@ func (d *Decoder) fillRegularObjectContent(obj core.Object) (uint32, error) { return crc, err } -func (d *Decoder) fillREFDeltaObjectContent(obj core.Object, ref core.Hash) (uint32, error) { +func (d *Decoder) fillREFDeltaObjectContent(obj plumbing.Object, ref plumbing.Hash) (uint32, error) { buf := bytes.NewBuffer(nil) _, crc, err := d.s.NextObject(buf) if err != nil { @@ -231,7 +232,7 @@ func (d *Decoder) fillREFDeltaObjectContent(obj core.Object, ref core.Hash) (uin return crc, ApplyDelta(obj, base, buf.Bytes()) } -func (d *Decoder) fillOFSDeltaObjectContent(obj core.Object, offset int64) (uint32, error) { +func (d *Decoder) fillOFSDeltaObjectContent(obj plumbing.Object, offset int64) (uint32, error) { buf := bytes.NewBuffer(nil) _, crc, err := d.s.NextObject(buf) if err != nil { @@ -247,55 +248,55 @@ func (d *Decoder) fillOFSDeltaObjectContent(obj core.Object, offset int64) (uint return crc, ApplyDelta(obj, base, buf.Bytes()) } -func (d *Decoder) setOffset(h core.Hash, offset int64) { +func (d *Decoder) setOffset(h plumbing.Hash, offset int64) { d.offsetToHash[offset] = h d.hashToOffset[h] = offset } -func (d *Decoder) setCRC(h core.Hash, crc uint32) { +func (d *Decoder) setCRC(h plumbing.Hash, crc uint32) { d.crcs[h] = crc } -func (d *Decoder) recallByOffset(o int64) (core.Object, error) { +func (d *Decoder) recallByOffset(o int64) (plumbing.Object, error) { if d.s.IsSeekable { return d.ReadObjectAt(o) } if h, ok := d.offsetToHash[o]; ok { - return d.tx.Object(core.AnyObject, h) + return d.tx.Object(plumbing.AnyObject, h) } - return nil, core.ErrObjectNotFound + return nil, plumbing.ErrObjectNotFound } -func (d *Decoder) recallByHash(h core.Hash) (core.Object, error) { +func (d *Decoder) recallByHash(h plumbing.Hash) (plumbing.Object, error) { if d.s.IsSeekable { if o, ok := d.hashToOffset[h]; ok { return d.ReadObjectAt(o) } } - obj, err := d.tx.Object(core.AnyObject, h) - if err != core.ErrObjectNotFound { + obj, err := d.tx.Object(plumbing.AnyObject, h) + if err != plumbing.ErrObjectNotFound { return obj, err } - return nil, core.ErrObjectNotFound + return nil, plumbing.ErrObjectNotFound } // SetOffsets sets the offsets, required when using the method ReadObjectAt, // without decoding the full packfile -func (d *Decoder) SetOffsets(offsets map[core.Hash]int64) { +func (d *Decoder) SetOffsets(offsets map[plumbing.Hash]int64) { d.hashToOffset = offsets } // Offsets returns the objects read offset -func (d *Decoder) Offsets() map[core.Hash]int64 { +func (d *Decoder) Offsets() map[plumbing.Hash]int64 { return d.hashToOffset } // CRCs returns the CRC-32 for each objected read -func (d *Decoder) CRCs() map[core.Hash]uint32 { +func (d *Decoder) CRCs() map[plumbing.Hash]uint32 { return d.crcs } diff --git a/formats/packfile/decoder_test.go b/plumbing/format/packfile/decoder_test.go index aa178d7..e510cf2 100644 --- a/formats/packfile/decoder_test.go +++ b/plumbing/format/packfile/decoder_test.go @@ -4,9 +4,9 @@ import ( "io" "testing" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" - "gopkg.in/src-d/go-git.v4/formats/idxfile" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/idxfile" "gopkg.in/src-d/go-git.v4/storage/memory" . "gopkg.in/check.v1" @@ -149,8 +149,8 @@ func (s *ReaderSuite) TestSetOffsets(c *C) { d, err := NewDecoder(scanner, nil) c.Assert(err, IsNil) - h := core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") - d.SetOffsets(map[core.Hash]int64{h: 42}) + h := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") + d.SetOffsets(map[plumbing.Hash]int64{h: 42}) o := d.Offsets() c.Assert(o, HasLen, 1) @@ -160,20 +160,20 @@ func (s *ReaderSuite) TestSetOffsets(c *C) { func assertObjects(c *C, s *memory.Storage, expects []string) { c.Assert(len(expects), Equals, len(s.Objects)) for _, exp := range expects { - obt, err := s.Object(core.AnyObject, core.NewHash(exp)) + obt, err := s.Object(plumbing.AnyObject, plumbing.NewHash(exp)) c.Assert(err, IsNil) c.Assert(obt.Hash().String(), Equals, exp) } } -func getOffsetsFromIdx(r io.Reader) map[core.Hash]int64 { +func getOffsetsFromIdx(r io.Reader) map[plumbing.Hash]int64 { idx := &idxfile.Idxfile{} err := idxfile.NewDecoder(r).Decode(idx) if err != nil { panic(err) } - offsets := make(map[core.Hash]int64) + offsets := make(map[plumbing.Hash]int64) for _, e := range idx.Entries { offsets[e.Hash] = int64(e.Offset) } diff --git a/formats/packfile/delta.go b/plumbing/format/packfile/delta.go index d08f969..2493a39 100644 --- a/formats/packfile/delta.go +++ b/plumbing/format/packfile/delta.go @@ -3,7 +3,7 @@ package packfile import ( "io/ioutil" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) // See https://github.com/git/git/blob/49fa3dc76179e04b0833542fa52d0f287a4955ac/delta.h @@ -14,7 +14,7 @@ import ( const deltaSizeMin = 4 // ApplyDelta writes to taget the result of applying the modification deltas in delta to base. -func ApplyDelta(target, base core.Object, delta []byte) error { +func ApplyDelta(target, base plumbing.Object, delta []byte) error { r, err := base.Reader() if err != nil { return err diff --git a/formats/packfile/doc.go b/plumbing/format/packfile/doc.go index 0b173ca..0b173ca 100644 --- a/formats/packfile/doc.go +++ b/plumbing/format/packfile/doc.go diff --git a/formats/packfile/error.go b/plumbing/format/packfile/error.go index c0b9163..c0b9163 100644 --- a/formats/packfile/error.go +++ b/plumbing/format/packfile/error.go diff --git a/formats/packfile/scanner.go b/plumbing/format/packfile/scanner.go index 69cc7d0..130bb94 100644 --- a/formats/packfile/scanner.go +++ b/plumbing/format/packfile/scanner.go @@ -10,7 +10,7 @@ import ( "io" "io/ioutil" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/utils/binary" ) @@ -34,10 +34,10 @@ const ( // ObjectHeader contains the information related to the object, this information // is collected from the previous bytes to the content of the object. type ObjectHeader struct { - Type core.ObjectType + Type plumbing.ObjectType Offset int64 Length int64 - Reference core.Hash + Reference plumbing.Hash OffsetReference int64 } @@ -166,14 +166,14 @@ func (s *Scanner) NextObjectHeader() (*ObjectHeader, error) { } switch h.Type { - case core.OFSDeltaObject: + case plumbing.OFSDeltaObject: no, err := binary.ReadVariableWidthInt(s.r) if err != nil { return nil, err } h.OffsetReference = h.Offset - no - case core.REFDeltaObject: + case plumbing.REFDeltaObject: var err error h.Reference, err = binary.ReadHash(s.r) if err != nil { @@ -219,7 +219,7 @@ func (s *Scanner) discardObjectIfNeeded() error { // ReadObjectTypeAndLength reads and returns the object type and the // length field from an object entry in a packfile. -func (s *Scanner) readObjectTypeAndLength() (core.ObjectType, int64, error) { +func (s *Scanner) readObjectTypeAndLength() (plumbing.ObjectType, int64, error) { t, c, err := s.readType() if err != nil { return t, 0, err @@ -239,11 +239,11 @@ const ( lengthBits = uint8(7) // subsequent bytes has 7 bits to store the length ) -func (s *Scanner) readType() (core.ObjectType, byte, error) { +func (s *Scanner) readType() (plumbing.ObjectType, byte, error) { var c byte var err error if c, err = s.r.ReadByte(); err != nil { - return core.ObjectType(0), 0, err + return plumbing.ObjectType(0), 0, err } typ := parseType(c) @@ -251,8 +251,8 @@ func (s *Scanner) readType() (core.ObjectType, byte, error) { return typ, c, nil } -func parseType(b byte) core.ObjectType { - return core.ObjectType((b & maskType) >> firstLengthBits) +func parseType(b byte) plumbing.ObjectType { + return plumbing.ObjectType((b & maskType) >> firstLengthBits) } // the length is codified in the last 4 bits of the first byte and in @@ -321,10 +321,10 @@ func (s *Scanner) Seek(offset int64) (previous int64, err error) { } // Checksum returns the checksum of the packfile -func (s *Scanner) Checksum() (core.Hash, error) { +func (s *Scanner) Checksum() (plumbing.Hash, error) { err := s.discardObjectIfNeeded() if err != nil { - return core.ZeroHash, err + return plumbing.ZeroHash, err } return binary.ReadHash(s.r) diff --git a/plumbing/format/packfile/scanner_test.go b/plumbing/format/packfile/scanner_test.go new file mode 100644 index 0000000..8e9a593 --- /dev/null +++ b/plumbing/format/packfile/scanner_test.go @@ -0,0 +1,189 @@ +package packfile + +import ( + "bytes" + "io" + + . "gopkg.in/check.v1" + "gopkg.in/src-d/go-git.v4/fixtures" + "gopkg.in/src-d/go-git.v4/plumbing" +) + +type ScannerSuite struct { + fixtures.Suite +} + +var _ = Suite(&ScannerSuite{}) + +func (s *ScannerSuite) TestHeader(c *C) { + r := fixtures.Basic().One().Packfile() + p := NewScanner(r) + + version, objects, err := p.Header() + c.Assert(err, IsNil) + c.Assert(version, Equals, VersionSupported) + c.Assert(objects, Equals, uint32(31)) +} + +func (s *ScannerSuite) TestNextObjectHeaderWithoutHeader(c *C) { + r := fixtures.Basic().One().Packfile() + p := NewScanner(r) + + h, err := p.NextObjectHeader() + c.Assert(err, IsNil) + c.Assert(h, DeepEquals, &expectedHeadersOFS[0]) + + version, objects, err := p.Header() + c.Assert(err, IsNil) + c.Assert(version, Equals, VersionSupported) + c.Assert(objects, Equals, uint32(31)) +} + +func (s *ScannerSuite) TestNextObjectHeaderREFDelta(c *C) { + s.testNextObjectHeader(c, "ref-delta", expectedHeadersREF) +} + +func (s *ScannerSuite) TestNextObjectHeaderOFSDelta(c *C) { + s.testNextObjectHeader(c, "ofs-delta", expectedHeadersOFS) +} + +func (s *ScannerSuite) testNextObjectHeader(c *C, tag string, expected []ObjectHeader) { + r := fixtures.Basic().ByTag(tag).One().Packfile() + p := NewScanner(r) + + _, objects, err := p.Header() + c.Assert(err, IsNil) + + for i := 0; i < int(objects); i++ { + h, err := p.NextObjectHeader() + c.Assert(err, IsNil) + c.Assert(*h, DeepEquals, expected[i]) + + buf := bytes.NewBuffer(nil) + n, _, err := p.NextObject(buf) + c.Assert(err, IsNil) + c.Assert(n, Equals, h.Length) + } + + n, err := p.Checksum() + c.Assert(err, IsNil) + c.Assert(n, HasLen, 20) +} + +func (s *ScannerSuite) TestNextObjectHeaderWithOutReadObject(c *C) { + f := fixtures.Basic().ByTag("ref-delta").One() + r := f.Packfile() + p := NewScanner(r) + + _, objects, err := p.Header() + c.Assert(err, IsNil) + + for i := 0; i < int(objects); i++ { + h, _ := p.NextObjectHeader() + c.Assert(err, IsNil) + c.Assert(*h, DeepEquals, expectedHeadersREF[i]) + } + + err = p.discardObjectIfNeeded() + c.Assert(err, IsNil) + + n, err := p.Checksum() + c.Assert(err, IsNil) + c.Assert(n, Equals, f.PackfileHash) +} + +func (s *ScannerSuite) TestNextObjectHeaderWithOutReadObjectNonSeekable(c *C) { + f := fixtures.Basic().ByTag("ref-delta").One() + r := io.MultiReader(f.Packfile()) + p := NewScanner(r) + + _, objects, err := p.Header() + c.Assert(err, IsNil) + + for i := 0; i < int(objects); i++ { + h, _ := p.NextObjectHeader() + c.Assert(err, IsNil) + c.Assert(*h, DeepEquals, expectedHeadersREF[i]) + } + + err = p.discardObjectIfNeeded() + c.Assert(err, IsNil) + + n, err := p.Checksum() + c.Assert(err, IsNil) + c.Assert(n, Equals, f.PackfileHash) +} + +var expectedHeadersOFS = []ObjectHeader{ + {Type: plumbing.CommitObject, Offset: 12, Length: 254}, + {Type: plumbing.OFSDeltaObject, Offset: 186, Length: 93, OffsetReference: 12}, + {Type: plumbing.CommitObject, Offset: 286, Length: 242}, + {Type: plumbing.CommitObject, Offset: 449, Length: 242}, + {Type: plumbing.CommitObject, Offset: 615, Length: 333}, + {Type: plumbing.CommitObject, Offset: 838, Length: 332}, + {Type: plumbing.CommitObject, Offset: 1063, Length: 244}, + {Type: plumbing.CommitObject, Offset: 1230, Length: 243}, + {Type: plumbing.CommitObject, Offset: 1392, Length: 187}, + {Type: plumbing.BlobObject, Offset: 1524, Length: 189}, + {Type: plumbing.BlobObject, Offset: 1685, Length: 18}, + {Type: plumbing.BlobObject, Offset: 1713, Length: 1072}, + {Type: plumbing.BlobObject, Offset: 2351, Length: 76110}, + {Type: plumbing.BlobObject, Offset: 78050, Length: 2780}, + {Type: plumbing.BlobObject, Offset: 78882, Length: 217848}, + {Type: plumbing.BlobObject, Offset: 80725, Length: 706}, + {Type: plumbing.BlobObject, Offset: 80998, Length: 11488}, + {Type: plumbing.BlobObject, Offset: 84032, Length: 78}, + {Type: plumbing.TreeObject, Offset: 84115, Length: 272}, + {Type: plumbing.OFSDeltaObject, Offset: 84375, Length: 43, OffsetReference: 84115}, + {Type: plumbing.TreeObject, Offset: 84430, Length: 38}, + {Type: plumbing.TreeObject, Offset: 84479, Length: 75}, + {Type: plumbing.TreeObject, Offset: 84559, Length: 38}, + {Type: plumbing.TreeObject, Offset: 84608, Length: 34}, + {Type: plumbing.BlobObject, Offset: 84653, Length: 9}, + {Type: plumbing.OFSDeltaObject, Offset: 84671, Length: 6, OffsetReference: 84375}, + {Type: plumbing.OFSDeltaObject, Offset: 84688, Length: 9, OffsetReference: 84375}, + {Type: plumbing.OFSDeltaObject, Offset: 84708, Length: 6, OffsetReference: 84375}, + {Type: plumbing.OFSDeltaObject, Offset: 84725, Length: 5, OffsetReference: 84115}, + {Type: plumbing.OFSDeltaObject, Offset: 84741, Length: 8, OffsetReference: 84375}, + {Type: plumbing.OFSDeltaObject, Offset: 84760, Length: 4, OffsetReference: 84741}, +} + +var expectedHeadersREF = []ObjectHeader{ + {Type: plumbing.CommitObject, Offset: 12, Length: 254}, + {Type: plumbing.REFDeltaObject, Offset: 186, Length: 93, + Reference: plumbing.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881")}, + {Type: plumbing.CommitObject, Offset: 304, Length: 242}, + {Type: plumbing.CommitObject, Offset: 467, Length: 242}, + {Type: plumbing.CommitObject, Offset: 633, Length: 333}, + {Type: plumbing.CommitObject, Offset: 856, Length: 332}, + {Type: plumbing.CommitObject, Offset: 1081, Length: 243}, + {Type: plumbing.CommitObject, Offset: 1243, Length: 244}, + {Type: plumbing.CommitObject, Offset: 1410, Length: 187}, + {Type: plumbing.BlobObject, Offset: 1542, Length: 189}, + {Type: plumbing.BlobObject, Offset: 1703, Length: 18}, + {Type: plumbing.BlobObject, Offset: 1731, Length: 1072}, + {Type: plumbing.BlobObject, Offset: 2369, Length: 76110}, + {Type: plumbing.TreeObject, Offset: 78068, Length: 38}, + {Type: plumbing.BlobObject, Offset: 78117, Length: 2780}, + {Type: plumbing.TreeObject, Offset: 79049, Length: 75}, + {Type: plumbing.BlobObject, Offset: 79129, Length: 217848}, + {Type: plumbing.BlobObject, Offset: 80972, Length: 706}, + {Type: plumbing.TreeObject, Offset: 81265, Length: 38}, + {Type: plumbing.BlobObject, Offset: 81314, Length: 11488}, + {Type: plumbing.TreeObject, Offset: 84752, Length: 34}, + {Type: plumbing.BlobObject, Offset: 84797, Length: 78}, + {Type: plumbing.TreeObject, Offset: 84880, Length: 271}, + {Type: plumbing.REFDeltaObject, Offset: 85141, Length: 6, + Reference: plumbing.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")}, + {Type: plumbing.REFDeltaObject, Offset: 85176, Length: 37, + Reference: plumbing.NewHash("fb72698cab7617ac416264415f13224dfd7a165e")}, + {Type: plumbing.BlobObject, Offset: 85244, Length: 9}, + {Type: plumbing.REFDeltaObject, Offset: 85262, Length: 9, + Reference: plumbing.NewHash("fb72698cab7617ac416264415f13224dfd7a165e")}, + {Type: plumbing.REFDeltaObject, Offset: 85300, Length: 6, + Reference: plumbing.NewHash("fb72698cab7617ac416264415f13224dfd7a165e")}, + {Type: plumbing.TreeObject, Offset: 85335, Length: 110}, + {Type: plumbing.REFDeltaObject, Offset: 85448, Length: 8, + Reference: plumbing.NewHash("eba74343e2f15d62adedfd8c883ee0262b5c8021")}, + {Type: plumbing.TreeObject, Offset: 85485, Length: 73}, +} diff --git a/formats/packp/advrefs/advrefs.go b/plumbing/format/packp/advrefs/advrefs.go index ab4bcf5..4d7c897 100644 --- a/formats/packp/advrefs/advrefs.go +++ b/plumbing/format/packp/advrefs/advrefs.go @@ -3,8 +3,8 @@ package advrefs import ( - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp" ) const ( @@ -39,11 +39,11 @@ var ( // be filled up with whatever is found on the line. type AdvRefs struct { Prefix [][]byte // payloads of the prefix - Head *core.Hash + Head *plumbing.Hash Capabilities *packp.Capabilities - References map[string]core.Hash - Peeled map[string]core.Hash - Shallows []core.Hash + References map[string]plumbing.Hash + Peeled map[string]plumbing.Hash + Shallows []plumbing.Hash } // New returns a pointer to a new AdvRefs value, ready to be used. @@ -51,8 +51,8 @@ func New() *AdvRefs { return &AdvRefs{ Prefix: [][]byte{}, Capabilities: packp.NewCapabilities(), - References: make(map[string]core.Hash), - Peeled: make(map[string]core.Hash), - Shallows: []core.Hash{}, + References: make(map[string]plumbing.Hash), + Peeled: make(map[string]plumbing.Hash), + Shallows: []plumbing.Hash{}, } } diff --git a/formats/packp/advrefs/advrefs_test.go b/plumbing/format/packp/advrefs/advrefs_test.go index 6950ba5..2639b6e 100644 --- a/formats/packp/advrefs/advrefs_test.go +++ b/plumbing/format/packp/advrefs/advrefs_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp/advrefs" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/advrefs" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" . "gopkg.in/check.v1" ) @@ -281,7 +281,7 @@ func ExampleEncoder_Encode() { ar := advrefs.New() // ...add a hash for the HEAD... - head := core.NewHash("1111111111111111111111111111111111111111") + head := plumbing.NewHash("1111111111111111111111111111111111111111") ar.Head = &head // ...add some server capabilities... @@ -290,14 +290,14 @@ func ExampleEncoder_Encode() { ar.Capabilities.Add("multi_ack") // ...add a couple of references... - ar.References["refs/heads/master"] = core.NewHash("2222222222222222222222222222222222222222") - ar.References["refs/tags/v1"] = core.NewHash("3333333333333333333333333333333333333333") + ar.References["refs/heads/master"] = plumbing.NewHash("2222222222222222222222222222222222222222") + ar.References["refs/tags/v1"] = plumbing.NewHash("3333333333333333333333333333333333333333") // ...including a peeled ref... - ar.Peeled["refs/tags/v1"] = core.NewHash("4444444444444444444444444444444444444444") + ar.Peeled["refs/tags/v1"] = plumbing.NewHash("4444444444444444444444444444444444444444") // ...and finally add a shallow - ar.Shallows = append(ar.Shallows, core.NewHash("5555555555555555555555555555555555555555")) + ar.Shallows = append(ar.Shallows, plumbing.NewHash("5555555555555555555555555555555555555555")) // Encode the advrefs.Contents to a bytes.Buffer. // You can encode into stdout too, but you will not be able diff --git a/formats/packp/advrefs/decoder.go b/plumbing/format/packp/advrefs/decoder.go index a0cf5e6..b654882 100644 --- a/formats/packp/advrefs/decoder.go +++ b/plumbing/format/packp/advrefs/decoder.go @@ -7,8 +7,8 @@ import ( "fmt" "io" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" ) // A Decoder reads and decodes AdvRef values from an input stream. @@ -16,7 +16,7 @@ type Decoder struct { s *pktline.Scanner // a pkt-line scanner from the input stream line []byte // current pkt-line contents, use parser.nextLine() to make it advance nLine int // current pkt-line number for debugging, begins at 1 - hash core.Hash // last hash read + hash plumbing.Hash // last hash read err error // sticky error, use the parser.error() method to fill this out data *AdvRefs // parsed data is stored here } @@ -240,15 +240,15 @@ func decodeOtherRefs(p *Decoder) decoderStateFn { } // Reads a ref-name -func readRef(data []byte) (string, core.Hash, error) { +func readRef(data []byte) (string, plumbing.Hash, error) { chunks := bytes.Split(data, sp) switch { case len(chunks) == 1: - return "", core.ZeroHash, fmt.Errorf("malformed ref data: no space was found") + return "", plumbing.ZeroHash, fmt.Errorf("malformed ref data: no space was found") case len(chunks) > 2: - return "", core.ZeroHash, fmt.Errorf("malformed ref data: more than one space found") + return "", plumbing.ZeroHash, fmt.Errorf("malformed ref data: more than one space found") default: - return string(chunks[1]), core.NewHash(string(chunks[0])), nil + return string(chunks[1]), plumbing.NewHash(string(chunks[0])), nil } } @@ -268,7 +268,7 @@ func decodeShallow(p *Decoder) decoderStateFn { } text := p.line[:hashSize] - var h core.Hash + var h plumbing.Hash if _, err := hex.Decode(h[:], text); err != nil { p.error("invalid hash text: %s", err) return nil diff --git a/formats/packp/advrefs/decoder_test.go b/plumbing/format/packp/advrefs/decoder_test.go index ee2f5ae..03867d3 100644 --- a/formats/packp/advrefs/decoder_test.go +++ b/plumbing/format/packp/advrefs/decoder_test.go @@ -5,10 +5,10 @@ import ( "io" "strings" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp" - "gopkg.in/src-d/go-git.v4/formats/packp/advrefs" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/advrefs" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" . "gopkg.in/check.v1" ) @@ -110,7 +110,7 @@ func (s *SuiteDecoder) TestHead(c *C) { } ar := testDecodeOK(c, payloads) c.Assert(*ar.Head, Equals, - core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) } func (s *SuiteDecoder) TestFirstIsNotHead(c *C) { @@ -121,7 +121,7 @@ func (s *SuiteDecoder) TestFirstIsNotHead(c *C) { ar := testDecodeOK(c, payloads) c.Assert(ar.Head, IsNil) c.Assert(ar.References["refs/heads/master"], Equals, - core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) } func (s *SuiteDecoder) TestShortRef(c *C) { @@ -269,36 +269,36 @@ func (s *SuiteDecoder) TestWithPrefixAndFlush(c *C) { func (s *SuiteDecoder) TestOtherRefs(c *C) { for _, test := range [...]struct { input []string - references map[string]core.Hash - peeled map[string]core.Hash + references map[string]plumbing.Hash + peeled map[string]plumbing.Hash }{ { input: []string{ "6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEAD\x00ofs-delta symref=HEAD:/refs/heads/master\n", pktline.FlushString, }, - references: make(map[string]core.Hash), - peeled: make(map[string]core.Hash), + references: make(map[string]plumbing.Hash), + peeled: make(map[string]plumbing.Hash), }, { input: []string{ "6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEAD\x00ofs-delta symref=HEAD:/refs/heads/master\n", "1111111111111111111111111111111111111111 ref/foo", pktline.FlushString, }, - references: map[string]core.Hash{ - "ref/foo": core.NewHash("1111111111111111111111111111111111111111"), + references: map[string]plumbing.Hash{ + "ref/foo": plumbing.NewHash("1111111111111111111111111111111111111111"), }, - peeled: make(map[string]core.Hash), + peeled: make(map[string]plumbing.Hash), }, { input: []string{ "6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEAD\x00ofs-delta symref=HEAD:/refs/heads/master\n", "1111111111111111111111111111111111111111 ref/foo\n", pktline.FlushString, }, - references: map[string]core.Hash{ - "ref/foo": core.NewHash("1111111111111111111111111111111111111111"), + references: map[string]plumbing.Hash{ + "ref/foo": plumbing.NewHash("1111111111111111111111111111111111111111"), }, - peeled: make(map[string]core.Hash), + peeled: make(map[string]plumbing.Hash), }, { input: []string{ "6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEAD\x00ofs-delta symref=HEAD:/refs/heads/master\n", @@ -306,20 +306,20 @@ func (s *SuiteDecoder) TestOtherRefs(c *C) { "2222222222222222222222222222222222222222 ref/bar", pktline.FlushString, }, - references: map[string]core.Hash{ - "ref/foo": core.NewHash("1111111111111111111111111111111111111111"), - "ref/bar": core.NewHash("2222222222222222222222222222222222222222"), + references: map[string]plumbing.Hash{ + "ref/foo": plumbing.NewHash("1111111111111111111111111111111111111111"), + "ref/bar": plumbing.NewHash("2222222222222222222222222222222222222222"), }, - peeled: make(map[string]core.Hash), + peeled: make(map[string]plumbing.Hash), }, { input: []string{ "6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEAD\x00ofs-delta symref=HEAD:/refs/heads/master\n", "1111111111111111111111111111111111111111 ref/foo^{}\n", pktline.FlushString, }, - references: make(map[string]core.Hash), - peeled: map[string]core.Hash{ - "ref/foo": core.NewHash("1111111111111111111111111111111111111111"), + references: make(map[string]plumbing.Hash), + peeled: map[string]plumbing.Hash{ + "ref/foo": plumbing.NewHash("1111111111111111111111111111111111111111"), }, }, { input: []string{ @@ -328,11 +328,11 @@ func (s *SuiteDecoder) TestOtherRefs(c *C) { "2222222222222222222222222222222222222222 ref/bar^{}", pktline.FlushString, }, - references: map[string]core.Hash{ - "ref/foo": core.NewHash("1111111111111111111111111111111111111111"), + references: map[string]plumbing.Hash{ + "ref/foo": plumbing.NewHash("1111111111111111111111111111111111111111"), }, - peeled: map[string]core.Hash{ - "ref/bar": core.NewHash("2222222222222222222222222222222222222222"), + peeled: map[string]plumbing.Hash{ + "ref/bar": plumbing.NewHash("2222222222222222222222222222222222222222"), }, }, { input: []string{ @@ -348,18 +348,18 @@ func (s *SuiteDecoder) TestOtherRefs(c *C) { "c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11-tree^{}\n", pktline.FlushString, }, - references: map[string]core.Hash{ - "refs/heads/master": core.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"), - "refs/pull/10/head": core.NewHash("51b8b4fb32271d39fbdd760397406177b2b0fd36"), - "refs/pull/100/head": core.NewHash("02b5a6031ba7a8cbfde5d65ff9e13ecdbc4a92ca"), - "refs/pull/100/merge": core.NewHash("c284c212704c43659bf5913656b8b28e32da1621"), - "refs/pull/101/merge": core.NewHash("3d6537dce68c8b7874333a1720958bd8db3ae8ca"), - "refs/tags/v2.6.11": core.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"), - "refs/tags/v2.6.11-tree": core.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"), + references: map[string]plumbing.Hash{ + "refs/heads/master": plumbing.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"), + "refs/pull/10/head": plumbing.NewHash("51b8b4fb32271d39fbdd760397406177b2b0fd36"), + "refs/pull/100/head": plumbing.NewHash("02b5a6031ba7a8cbfde5d65ff9e13ecdbc4a92ca"), + "refs/pull/100/merge": plumbing.NewHash("c284c212704c43659bf5913656b8b28e32da1621"), + "refs/pull/101/merge": plumbing.NewHash("3d6537dce68c8b7874333a1720958bd8db3ae8ca"), + "refs/tags/v2.6.11": plumbing.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"), + "refs/tags/v2.6.11-tree": plumbing.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"), }, - peeled: map[string]core.Hash{ - "refs/tags/v2.6.11": core.NewHash("c39ae07f393806ccf406ef966e9a15afc43cc36a"), - "refs/tags/v2.6.11-tree": core.NewHash("c39ae07f393806ccf406ef966e9a15afc43cc36a"), + peeled: map[string]plumbing.Hash{ + "refs/tags/v2.6.11": plumbing.NewHash("c39ae07f393806ccf406ef966e9a15afc43cc36a"), + "refs/tags/v2.6.11-tree": plumbing.NewHash("c39ae07f393806ccf406ef966e9a15afc43cc36a"), }, }, } { @@ -393,7 +393,7 @@ func (s *SuiteDecoder) TestMalformedOtherRefsMultipleSpaces(c *C) { func (s *SuiteDecoder) TestShallow(c *C) { for _, test := range [...]struct { input []string - shallows []core.Hash + shallows []plumbing.Hash }{ { input: []string{ @@ -403,7 +403,7 @@ func (s *SuiteDecoder) TestShallow(c *C) { "c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11-tree^{}\n", pktline.FlushString, }, - shallows: []core.Hash{}, + shallows: []plumbing.Hash{}, }, { input: []string{ "6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEAD\x00ofs-delta symref=HEAD:/refs/heads/master\n", @@ -413,7 +413,7 @@ func (s *SuiteDecoder) TestShallow(c *C) { "shallow 1111111111111111111111111111111111111111\n", pktline.FlushString, }, - shallows: []core.Hash{core.NewHash("1111111111111111111111111111111111111111")}, + shallows: []plumbing.Hash{plumbing.NewHash("1111111111111111111111111111111111111111")}, }, { input: []string{ "6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEAD\x00ofs-delta symref=HEAD:/refs/heads/master\n", @@ -424,9 +424,9 @@ func (s *SuiteDecoder) TestShallow(c *C) { "shallow 2222222222222222222222222222222222222222\n", pktline.FlushString, }, - shallows: []core.Hash{ - core.NewHash("1111111111111111111111111111111111111111"), - core.NewHash("2222222222222222222222222222222222222222"), + shallows: []plumbing.Hash{ + plumbing.NewHash("1111111111111111111111111111111111111111"), + plumbing.NewHash("2222222222222222222222222222222222222222"), }, }, } { diff --git a/formats/packp/advrefs/encoder.go b/plumbing/format/packp/advrefs/encoder.go index 9874884..8c52f14 100644 --- a/formats/packp/advrefs/encoder.go +++ b/plumbing/format/packp/advrefs/encoder.go @@ -5,9 +5,9 @@ import ( "io" "sort" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" ) // An Encoder writes AdvRefs values to an output stream. @@ -71,15 +71,15 @@ func encodeFirstLine(e *Encoder) encoderStateFn { return encodeRefs } -func formatHead(h *core.Hash) string { +func formatHead(h *plumbing.Hash) string { if h == nil { - return core.ZeroHash.String() + return plumbing.ZeroHash.String() } return h.String() } -func formatSeparator(h *core.Hash) string { +func formatSeparator(h *plumbing.Hash) string { if h == nil { return noHead } @@ -117,7 +117,7 @@ func encodeRefs(e *Encoder) encoderStateFn { return encodeShallow } -func sortRefs(m map[string]core.Hash) []string { +func sortRefs(m map[string]plumbing.Hash) []string { ret := make([]string, 0, len(m)) for k := range m { ret = append(ret, k) @@ -139,7 +139,7 @@ func encodeShallow(e *Encoder) encoderStateFn { return encodeFlush } -func sortShallows(c []core.Hash) []string { +func sortShallows(c []plumbing.Hash) []string { ret := []string{} for _, h := range c { ret = append(ret, h.String()) diff --git a/formats/packp/advrefs/encoder_test.go b/plumbing/format/packp/advrefs/encoder_test.go index 8fb475b..b4b085c 100644 --- a/formats/packp/advrefs/encoder_test.go +++ b/plumbing/format/packp/advrefs/encoder_test.go @@ -4,10 +4,10 @@ import ( "bytes" "strings" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp" - "gopkg.in/src-d/go-git.v4/formats/packp/advrefs" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/advrefs" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" . "gopkg.in/check.v1" ) @@ -50,7 +50,7 @@ func (s *SuiteEncoder) TestZeroValue(c *C) { } func (s *SuiteEncoder) TestHead(c *C) { - hash := core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") + hash := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") ar := &advrefs.AdvRefs{ Head: &hash, } @@ -81,7 +81,7 @@ func (s *SuiteEncoder) TestCapsNoHead(c *C) { } func (s *SuiteEncoder) TestCapsWithHead(c *C) { - hash := core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") + hash := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") capabilities := packp.NewCapabilities() capabilities.Add("symref", "HEAD:/refs/heads/master") capabilities.Add("ofs-delta") @@ -100,12 +100,12 @@ func (s *SuiteEncoder) TestCapsWithHead(c *C) { } func (s *SuiteEncoder) TestRefs(c *C) { - references := map[string]core.Hash{ - "refs/heads/master": core.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"), - "refs/tags/v2.6.12-tree": core.NewHash("1111111111111111111111111111111111111111"), - "refs/tags/v2.7.13-tree": core.NewHash("3333333333333333333333333333333333333333"), - "refs/tags/v2.6.13-tree": core.NewHash("2222222222222222222222222222222222222222"), - "refs/tags/v2.6.11-tree": core.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"), + references := map[string]plumbing.Hash{ + "refs/heads/master": plumbing.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"), + "refs/tags/v2.6.12-tree": plumbing.NewHash("1111111111111111111111111111111111111111"), + "refs/tags/v2.7.13-tree": plumbing.NewHash("3333333333333333333333333333333333333333"), + "refs/tags/v2.6.13-tree": plumbing.NewHash("2222222222222222222222222222222222222222"), + "refs/tags/v2.6.11-tree": plumbing.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"), } ar := &advrefs.AdvRefs{ References: references, @@ -125,16 +125,16 @@ func (s *SuiteEncoder) TestRefs(c *C) { } func (s *SuiteEncoder) TestPeeled(c *C) { - references := map[string]core.Hash{ - "refs/heads/master": core.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"), - "refs/tags/v2.6.12-tree": core.NewHash("1111111111111111111111111111111111111111"), - "refs/tags/v2.7.13-tree": core.NewHash("3333333333333333333333333333333333333333"), - "refs/tags/v2.6.13-tree": core.NewHash("2222222222222222222222222222222222222222"), - "refs/tags/v2.6.11-tree": core.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"), + references := map[string]plumbing.Hash{ + "refs/heads/master": plumbing.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"), + "refs/tags/v2.6.12-tree": plumbing.NewHash("1111111111111111111111111111111111111111"), + "refs/tags/v2.7.13-tree": plumbing.NewHash("3333333333333333333333333333333333333333"), + "refs/tags/v2.6.13-tree": plumbing.NewHash("2222222222222222222222222222222222222222"), + "refs/tags/v2.6.11-tree": plumbing.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"), } - peeled := map[string]core.Hash{ - "refs/tags/v2.7.13-tree": core.NewHash("4444444444444444444444444444444444444444"), - "refs/tags/v2.6.12-tree": core.NewHash("5555555555555555555555555555555555555555"), + peeled := map[string]plumbing.Hash{ + "refs/tags/v2.7.13-tree": plumbing.NewHash("4444444444444444444444444444444444444444"), + "refs/tags/v2.6.12-tree": plumbing.NewHash("5555555555555555555555555555555555555555"), } ar := &advrefs.AdvRefs{ References: references, @@ -157,11 +157,11 @@ func (s *SuiteEncoder) TestPeeled(c *C) { } func (s *SuiteEncoder) TestShallow(c *C) { - shallows := []core.Hash{ - core.NewHash("1111111111111111111111111111111111111111"), - core.NewHash("4444444444444444444444444444444444444444"), - core.NewHash("3333333333333333333333333333333333333333"), - core.NewHash("2222222222222222222222222222222222222222"), + shallows := []plumbing.Hash{ + plumbing.NewHash("1111111111111111111111111111111111111111"), + plumbing.NewHash("4444444444444444444444444444444444444444"), + plumbing.NewHash("3333333333333333333333333333333333333333"), + plumbing.NewHash("2222222222222222222222222222222222222222"), } ar := &advrefs.AdvRefs{ Shallows: shallows, @@ -180,31 +180,31 @@ func (s *SuiteEncoder) TestShallow(c *C) { } func (s *SuiteEncoder) TestAll(c *C) { - hash := core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") + hash := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") capabilities := packp.NewCapabilities() capabilities.Add("symref", "HEAD:/refs/heads/master") capabilities.Add("ofs-delta") capabilities.Add("multi_ack") - references := map[string]core.Hash{ - "refs/heads/master": core.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"), - "refs/tags/v2.6.12-tree": core.NewHash("1111111111111111111111111111111111111111"), - "refs/tags/v2.7.13-tree": core.NewHash("3333333333333333333333333333333333333333"), - "refs/tags/v2.6.13-tree": core.NewHash("2222222222222222222222222222222222222222"), - "refs/tags/v2.6.11-tree": core.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"), + references := map[string]plumbing.Hash{ + "refs/heads/master": plumbing.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"), + "refs/tags/v2.6.12-tree": plumbing.NewHash("1111111111111111111111111111111111111111"), + "refs/tags/v2.7.13-tree": plumbing.NewHash("3333333333333333333333333333333333333333"), + "refs/tags/v2.6.13-tree": plumbing.NewHash("2222222222222222222222222222222222222222"), + "refs/tags/v2.6.11-tree": plumbing.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"), } - peeled := map[string]core.Hash{ - "refs/tags/v2.7.13-tree": core.NewHash("4444444444444444444444444444444444444444"), - "refs/tags/v2.6.12-tree": core.NewHash("5555555555555555555555555555555555555555"), + peeled := map[string]plumbing.Hash{ + "refs/tags/v2.7.13-tree": plumbing.NewHash("4444444444444444444444444444444444444444"), + "refs/tags/v2.6.12-tree": plumbing.NewHash("5555555555555555555555555555555555555555"), } - shallows := []core.Hash{ - core.NewHash("1111111111111111111111111111111111111111"), - core.NewHash("4444444444444444444444444444444444444444"), - core.NewHash("3333333333333333333333333333333333333333"), - core.NewHash("2222222222222222222222222222222222222222"), + shallows := []plumbing.Hash{ + plumbing.NewHash("1111111111111111111111111111111111111111"), + plumbing.NewHash("4444444444444444444444444444444444444444"), + plumbing.NewHash("3333333333333333333333333333333333333333"), + plumbing.NewHash("2222222222222222222222222222222222222222"), } ar := &advrefs.AdvRefs{ @@ -235,8 +235,8 @@ func (s *SuiteEncoder) TestAll(c *C) { } func (s *SuiteEncoder) TestErrorTooLong(c *C) { - references := map[string]core.Hash{ - strings.Repeat("a", pktline.MaxPayloadSize): core.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"), + references := map[string]plumbing.Hash{ + strings.Repeat("a", pktline.MaxPayloadSize): plumbing.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"), } ar := &advrefs.AdvRefs{ References: references, diff --git a/formats/packp/capabilities.go b/plumbing/format/packp/capabilities.go index d77c2fa..d77c2fa 100644 --- a/formats/packp/capabilities.go +++ b/plumbing/format/packp/capabilities.go diff --git a/formats/packp/capabilities_test.go b/plumbing/format/packp/capabilities_test.go index e42a0c7..e42a0c7 100644 --- a/formats/packp/capabilities_test.go +++ b/plumbing/format/packp/capabilities_test.go diff --git a/formats/packp/doc.go b/plumbing/format/packp/doc.go index 4950d1d..4950d1d 100644 --- a/formats/packp/doc.go +++ b/plumbing/format/packp/doc.go diff --git a/formats/packp/pktline/encoder.go b/plumbing/format/packp/pktline/encoder.go index 0a88a9b..0a88a9b 100644 --- a/formats/packp/pktline/encoder.go +++ b/plumbing/format/packp/pktline/encoder.go diff --git a/formats/packp/pktline/encoder_test.go b/plumbing/format/packp/pktline/encoder_test.go index 618002d..cd97593 100644 --- a/formats/packp/pktline/encoder_test.go +++ b/plumbing/format/packp/pktline/encoder_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" . "gopkg.in/check.v1" ) diff --git a/formats/packp/pktline/scanner.go b/plumbing/format/packp/pktline/scanner.go index 3ce2adf..3ce2adf 100644 --- a/formats/packp/pktline/scanner.go +++ b/plumbing/format/packp/pktline/scanner.go diff --git a/formats/packp/pktline/scanner_test.go b/plumbing/format/packp/pktline/scanner_test.go index b5a3c7d..c5395cf 100644 --- a/formats/packp/pktline/scanner_test.go +++ b/plumbing/format/packp/pktline/scanner_test.go @@ -6,7 +6,7 @@ import ( "io" "strings" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" . "gopkg.in/check.v1" ) diff --git a/formats/packp/ulreq/decoder.go b/plumbing/format/packp/ulreq/decoder.go index 63ccd4d..9083e04 100644 --- a/formats/packp/ulreq/decoder.go +++ b/plumbing/format/packp/ulreq/decoder.go @@ -8,8 +8,8 @@ import ( "strconv" "time" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" ) const ( @@ -108,16 +108,16 @@ func decodeFirstWant(d *Decoder) decoderStateFn { return decodeCaps } -func (d *Decoder) readHash() (core.Hash, bool) { +func (d *Decoder) readHash() (plumbing.Hash, bool) { if len(d.line) < hashSize { d.err = fmt.Errorf("malformed hash: %v", d.line) - return core.ZeroHash, false + return plumbing.ZeroHash, false } - var hash core.Hash + var hash plumbing.Hash if _, err := hex.Decode(hash[:], d.line[:hashSize]); err != nil { d.error("invalid hash text: %s", err) - return core.ZeroHash, false + return plumbing.ZeroHash, false } d.line = d.line[hashSize:] diff --git a/formats/packp/ulreq/decoder_test.go b/plumbing/format/packp/ulreq/decoder_test.go index b313395..01e4f90 100644 --- a/formats/packp/ulreq/decoder_test.go +++ b/plumbing/format/packp/ulreq/decoder_test.go @@ -6,8 +6,8 @@ import ( "sort" "time" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" . "gopkg.in/check.v1" ) @@ -67,8 +67,8 @@ func (s *SuiteDecoder) TestWantOK(c *C) { } ur := testDecodeOK(c, payloads) - c.Assert(ur.Wants, DeepEquals, []core.Hash{ - core.NewHash("1111111111111111111111111111111111111111"), + c.Assert(ur.Wants, DeepEquals, []plumbing.Hash{ + plumbing.NewHash("1111111111111111111111111111111111111111"), }) } @@ -93,8 +93,8 @@ func (s *SuiteDecoder) TestWantWithCapabilities(c *C) { pktline.FlushString, } ur := testDecodeOK(c, payloads) - c.Assert(ur.Wants, DeepEquals, []core.Hash{ - core.NewHash("1111111111111111111111111111111111111111")}) + c.Assert(ur.Wants, DeepEquals, []plumbing.Hash{ + plumbing.NewHash("1111111111111111111111111111111111111111")}) c.Assert(ur.Capabilities.Supports("ofs-delta"), Equals, true) c.Assert(ur.Capabilities.Supports("multi_ack"), Equals, true) @@ -110,11 +110,11 @@ func (s *SuiteDecoder) TestManyWantsNoCapabilities(c *C) { } ur := testDecodeOK(c, payloads) - expected := []core.Hash{ - core.NewHash("1111111111111111111111111111111111111111"), - core.NewHash("2222222222222222222222222222222222222222"), - core.NewHash("3333333333333333333333333333333333333333"), - core.NewHash("4444444444444444444444444444444444444444"), + expected := []plumbing.Hash{ + plumbing.NewHash("1111111111111111111111111111111111111111"), + plumbing.NewHash("2222222222222222222222222222222222222222"), + plumbing.NewHash("3333333333333333333333333333333333333333"), + plumbing.NewHash("4444444444444444444444444444444444444444"), } sort.Sort(byHash(ur.Wants)) @@ -122,7 +122,7 @@ func (s *SuiteDecoder) TestManyWantsNoCapabilities(c *C) { c.Assert(ur.Wants, DeepEquals, expected) } -type byHash []core.Hash +type byHash []plumbing.Hash func (a byHash) Len() int { return len(a) } func (a byHash) Swap(i, j int) { a[i], a[j] = a[j], a[i] } @@ -166,11 +166,11 @@ func (s *SuiteDecoder) TestManyWantsWithCapabilities(c *C) { } ur := testDecodeOK(c, payloads) - expected := []core.Hash{ - core.NewHash("1111111111111111111111111111111111111111"), - core.NewHash("2222222222222222222222222222222222222222"), - core.NewHash("3333333333333333333333333333333333333333"), - core.NewHash("4444444444444444444444444444444444444444"), + expected := []plumbing.Hash{ + plumbing.NewHash("1111111111111111111111111111111111111111"), + plumbing.NewHash("2222222222222222222222222222222222222222"), + plumbing.NewHash("3333333333333333333333333333333333333333"), + plumbing.NewHash("4444444444444444444444444444444444444444"), } sort.Sort(byHash(ur.Wants)) @@ -189,12 +189,12 @@ func (s *SuiteDecoder) TestSingleShallowSingleWant(c *C) { } ur := testDecodeOK(c, payloads) - expectedWants := []core.Hash{ - core.NewHash("3333333333333333333333333333333333333333"), + expectedWants := []plumbing.Hash{ + plumbing.NewHash("3333333333333333333333333333333333333333"), } - expectedShallows := []core.Hash{ - core.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + expectedShallows := []plumbing.Hash{ + plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), } c.Assert(ur.Wants, DeepEquals, expectedWants) @@ -215,16 +215,16 @@ func (s *SuiteDecoder) TestSingleShallowManyWants(c *C) { } ur := testDecodeOK(c, payloads) - expectedWants := []core.Hash{ - core.NewHash("1111111111111111111111111111111111111111"), - core.NewHash("2222222222222222222222222222222222222222"), - core.NewHash("3333333333333333333333333333333333333333"), - core.NewHash("4444444444444444444444444444444444444444"), + expectedWants := []plumbing.Hash{ + plumbing.NewHash("1111111111111111111111111111111111111111"), + plumbing.NewHash("2222222222222222222222222222222222222222"), + plumbing.NewHash("3333333333333333333333333333333333333333"), + plumbing.NewHash("4444444444444444444444444444444444444444"), } sort.Sort(byHash(expectedWants)) - expectedShallows := []core.Hash{ - core.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + expectedShallows := []plumbing.Hash{ + plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), } sort.Sort(byHash(ur.Wants)) @@ -246,15 +246,15 @@ func (s *SuiteDecoder) TestManyShallowSingleWant(c *C) { } ur := testDecodeOK(c, payloads) - expectedWants := []core.Hash{ - core.NewHash("3333333333333333333333333333333333333333"), + expectedWants := []plumbing.Hash{ + plumbing.NewHash("3333333333333333333333333333333333333333"), } - expectedShallows := []core.Hash{ - core.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - core.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), - core.NewHash("cccccccccccccccccccccccccccccccccccccccc"), - core.NewHash("dddddddddddddddddddddddddddddddddddddddd"), + expectedShallows := []plumbing.Hash{ + plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + plumbing.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), + plumbing.NewHash("cccccccccccccccccccccccccccccccccccccccc"), + plumbing.NewHash("dddddddddddddddddddddddddddddddddddddddd"), } sort.Sort(byHash(expectedShallows)) @@ -280,19 +280,19 @@ func (s *SuiteDecoder) TestManyShallowManyWants(c *C) { } ur := testDecodeOK(c, payloads) - expectedWants := []core.Hash{ - core.NewHash("1111111111111111111111111111111111111111"), - core.NewHash("2222222222222222222222222222222222222222"), - core.NewHash("3333333333333333333333333333333333333333"), - core.NewHash("4444444444444444444444444444444444444444"), + expectedWants := []plumbing.Hash{ + plumbing.NewHash("1111111111111111111111111111111111111111"), + plumbing.NewHash("2222222222222222222222222222222222222222"), + plumbing.NewHash("3333333333333333333333333333333333333333"), + plumbing.NewHash("4444444444444444444444444444444444444444"), } sort.Sort(byHash(expectedWants)) - expectedShallows := []core.Hash{ - core.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - core.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), - core.NewHash("cccccccccccccccccccccccccccccccccccccccc"), - core.NewHash("dddddddddddddddddddddddddddddddddddddddd"), + expectedShallows := []plumbing.Hash{ + plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + plumbing.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), + plumbing.NewHash("cccccccccccccccccccccccccccccccccccccccc"), + plumbing.NewHash("dddddddddddddddddddddddddddddddddddddddd"), } sort.Sort(byHash(expectedShallows)) @@ -500,11 +500,11 @@ func (s *SuiteDecoder) TestAll(c *C) { } ur := testDecodeOK(c, payloads) - expectedWants := []core.Hash{ - core.NewHash("1111111111111111111111111111111111111111"), - core.NewHash("2222222222222222222222222222222222222222"), - core.NewHash("3333333333333333333333333333333333333333"), - core.NewHash("4444444444444444444444444444444444444444"), + expectedWants := []plumbing.Hash{ + plumbing.NewHash("1111111111111111111111111111111111111111"), + plumbing.NewHash("2222222222222222222222222222222222222222"), + plumbing.NewHash("3333333333333333333333333333333333333333"), + plumbing.NewHash("4444444444444444444444444444444444444444"), } sort.Sort(byHash(expectedWants)) sort.Sort(byHash(ur.Wants)) @@ -513,11 +513,11 @@ func (s *SuiteDecoder) TestAll(c *C) { c.Assert(ur.Capabilities.Supports("ofs-delta"), Equals, true) c.Assert(ur.Capabilities.Supports("multi_ack"), Equals, true) - expectedShallows := []core.Hash{ - core.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - core.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), - core.NewHash("cccccccccccccccccccccccccccccccccccccccc"), - core.NewHash("dddddddddddddddddddddddddddddddddddddddd"), + expectedShallows := []plumbing.Hash{ + plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + plumbing.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), + plumbing.NewHash("cccccccccccccccccccccccccccccccccccccccc"), + plumbing.NewHash("dddddddddddddddddddddddddddddddddddddddd"), } sort.Sort(byHash(expectedShallows)) sort.Sort(byHash(ur.Shallows)) diff --git a/formats/packp/ulreq/encoder.go b/plumbing/format/packp/ulreq/encoder.go index 1e40b63..1264e0e 100644 --- a/formats/packp/ulreq/encoder.go +++ b/plumbing/format/packp/ulreq/encoder.go @@ -6,8 +6,8 @@ import ( "sort" "time" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" ) // An Encoder writes UlReq values to an output stream. @@ -47,7 +47,7 @@ func (e *Encoder) Encode(v *UlReq) error { type encoderStateFn func(*Encoder) encoderStateFn -func sortHashes(list []core.Hash) []string { +func sortHashes(list []plumbing.Hash) []string { sorted := make([]string, len(list)) for i, hash := range list { sorted[i] = hash.String() diff --git a/formats/packp/ulreq/encoder_test.go b/plumbing/format/packp/ulreq/encoder_test.go index 56a8c2a..44c6d26 100644 --- a/formats/packp/ulreq/encoder_test.go +++ b/plumbing/format/packp/ulreq/encoder_test.go @@ -4,8 +4,8 @@ import ( "bytes" "time" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" . "gopkg.in/check.v1" ) @@ -57,7 +57,7 @@ func (s *SuiteEncoder) TestZeroValue(c *C) { func (s *SuiteEncoder) TestOneWant(c *C) { ur := New() - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) expected := []string{ "want 1111111111111111111111111111111111111111\n", @@ -69,7 +69,7 @@ func (s *SuiteEncoder) TestOneWant(c *C) { func (s *SuiteEncoder) TestOneWantWithCapabilities(c *C) { ur := New() - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) ur.Capabilities.Add("sysref", "HEAD:/refs/heads/master") ur.Capabilities.Add("multi_ack") ur.Capabilities.Add("thin-pack") @@ -86,11 +86,11 @@ func (s *SuiteEncoder) TestOneWantWithCapabilities(c *C) { func (s *SuiteEncoder) TestWants(c *C) { ur := New() - ur.Wants = append(ur.Wants, core.NewHash("4444444444444444444444444444444444444444")) - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) - ur.Wants = append(ur.Wants, core.NewHash("3333333333333333333333333333333333333333")) - ur.Wants = append(ur.Wants, core.NewHash("2222222222222222222222222222222222222222")) - ur.Wants = append(ur.Wants, core.NewHash("5555555555555555555555555555555555555555")) + ur.Wants = append(ur.Wants, plumbing.NewHash("4444444444444444444444444444444444444444")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("3333333333333333333333333333333333333333")) + ur.Wants = append(ur.Wants, plumbing.NewHash("2222222222222222222222222222222222222222")) + ur.Wants = append(ur.Wants, plumbing.NewHash("5555555555555555555555555555555555555555")) expected := []string{ "want 1111111111111111111111111111111111111111\n", @@ -106,11 +106,11 @@ func (s *SuiteEncoder) TestWants(c *C) { func (s *SuiteEncoder) TestWantsWithCapabilities(c *C) { ur := New() - ur.Wants = append(ur.Wants, core.NewHash("4444444444444444444444444444444444444444")) - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) - ur.Wants = append(ur.Wants, core.NewHash("3333333333333333333333333333333333333333")) - ur.Wants = append(ur.Wants, core.NewHash("2222222222222222222222222222222222222222")) - ur.Wants = append(ur.Wants, core.NewHash("5555555555555555555555555555555555555555")) + ur.Wants = append(ur.Wants, plumbing.NewHash("4444444444444444444444444444444444444444")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("3333333333333333333333333333333333333333")) + ur.Wants = append(ur.Wants, plumbing.NewHash("2222222222222222222222222222222222222222")) + ur.Wants = append(ur.Wants, plumbing.NewHash("5555555555555555555555555555555555555555")) ur.Capabilities.Add("sysref", "HEAD:/refs/heads/master") ur.Capabilities.Add("multi_ack") @@ -132,9 +132,9 @@ func (s *SuiteEncoder) TestWantsWithCapabilities(c *C) { func (s *SuiteEncoder) TestShallow(c *C) { ur := New() - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) ur.Capabilities.Add("multi_ack") - ur.Shallows = append(ur.Shallows, core.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) + ur.Shallows = append(ur.Shallows, plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) expected := []string{ "want 1111111111111111111111111111111111111111 multi_ack\n", @@ -147,12 +147,12 @@ func (s *SuiteEncoder) TestShallow(c *C) { func (s *SuiteEncoder) TestManyShallows(c *C) { ur := New() - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) ur.Capabilities.Add("multi_ack") - ur.Shallows = append(ur.Shallows, core.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) - ur.Shallows = append(ur.Shallows, core.NewHash("dddddddddddddddddddddddddddddddddddddddd")) - ur.Shallows = append(ur.Shallows, core.NewHash("cccccccccccccccccccccccccccccccccccccccc")) - ur.Shallows = append(ur.Shallows, core.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) + ur.Shallows = append(ur.Shallows, plumbing.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) + ur.Shallows = append(ur.Shallows, plumbing.NewHash("dddddddddddddddddddddddddddddddddddddddd")) + ur.Shallows = append(ur.Shallows, plumbing.NewHash("cccccccccccccccccccccccccccccccccccccccc")) + ur.Shallows = append(ur.Shallows, plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) expected := []string{ "want 1111111111111111111111111111111111111111 multi_ack\n", @@ -168,7 +168,7 @@ func (s *SuiteEncoder) TestManyShallows(c *C) { func (s *SuiteEncoder) TestDepthCommits(c *C) { ur := New() - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) ur.Depth = DepthCommits(1234) expected := []string{ @@ -182,7 +182,7 @@ func (s *SuiteEncoder) TestDepthCommits(c *C) { func (s *SuiteEncoder) TestDepthSinceUTC(c *C) { ur := New() - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) since := time.Date(2015, time.January, 2, 3, 4, 5, 0, time.UTC) ur.Depth = DepthSince(since) @@ -197,7 +197,7 @@ func (s *SuiteEncoder) TestDepthSinceUTC(c *C) { func (s *SuiteEncoder) TestDepthSinceNonUTC(c *C) { ur := New() - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) berlin, err := time.LoadLocation("Europe/Berlin") c.Assert(err, IsNil) since := time.Date(2015, time.January, 2, 3, 4, 5, 0, berlin) @@ -216,7 +216,7 @@ func (s *SuiteEncoder) TestDepthSinceNonUTC(c *C) { func (s *SuiteEncoder) TestDepthReference(c *C) { ur := New() - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) ur.Depth = DepthReference("refs/heads/feature-foo") expected := []string{ @@ -230,11 +230,11 @@ func (s *SuiteEncoder) TestDepthReference(c *C) { func (s *SuiteEncoder) TestAll(c *C) { ur := New() - ur.Wants = append(ur.Wants, core.NewHash("4444444444444444444444444444444444444444")) - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) - ur.Wants = append(ur.Wants, core.NewHash("3333333333333333333333333333333333333333")) - ur.Wants = append(ur.Wants, core.NewHash("2222222222222222222222222222222222222222")) - ur.Wants = append(ur.Wants, core.NewHash("5555555555555555555555555555555555555555")) + ur.Wants = append(ur.Wants, plumbing.NewHash("4444444444444444444444444444444444444444")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("3333333333333333333333333333333333333333")) + ur.Wants = append(ur.Wants, plumbing.NewHash("2222222222222222222222222222222222222222")) + ur.Wants = append(ur.Wants, plumbing.NewHash("5555555555555555555555555555555555555555")) ur.Capabilities.Add("sysref", "HEAD:/refs/heads/master") ur.Capabilities.Add("multi_ack") @@ -242,10 +242,10 @@ func (s *SuiteEncoder) TestAll(c *C) { ur.Capabilities.Add("side-band") ur.Capabilities.Add("ofs-delta") - ur.Shallows = append(ur.Shallows, core.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) - ur.Shallows = append(ur.Shallows, core.NewHash("dddddddddddddddddddddddddddddddddddddddd")) - ur.Shallows = append(ur.Shallows, core.NewHash("cccccccccccccccccccccccccccccccccccccccc")) - ur.Shallows = append(ur.Shallows, core.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) + ur.Shallows = append(ur.Shallows, plumbing.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) + ur.Shallows = append(ur.Shallows, plumbing.NewHash("dddddddddddddddddddddddddddddddddddddddd")) + ur.Shallows = append(ur.Shallows, plumbing.NewHash("cccccccccccccccccccccccccccccccccccccccc")) + ur.Shallows = append(ur.Shallows, plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) since := time.Date(2015, time.January, 2, 3, 4, 5, 0, time.UTC) ur.Depth = DepthSince(since) diff --git a/formats/packp/ulreq/ulreq.go b/plumbing/format/packp/ulreq/ulreq.go index e47450a..d2cc7c0 100644 --- a/formats/packp/ulreq/ulreq.go +++ b/plumbing/format/packp/ulreq/ulreq.go @@ -5,8 +5,8 @@ package ulreq import ( "time" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp" ) // UlReq values represent the information transmitted on a @@ -14,8 +14,8 @@ import ( // safe, use the New function instead. type UlReq struct { Capabilities *packp.Capabilities - Wants []core.Hash - Shallows []core.Hash + Wants []plumbing.Hash + Shallows []plumbing.Hash Depth Depth } @@ -49,8 +49,8 @@ func (d DepthReference) isDepth() {} func New() *UlReq { return &UlReq{ Capabilities: packp.NewCapabilities(), - Wants: []core.Hash{}, - Shallows: []core.Hash{}, + Wants: []plumbing.Hash{}, + Shallows: []plumbing.Hash{}, Depth: DepthCommits(0), } } diff --git a/formats/packp/ulreq/ulreq_test.go b/plumbing/format/packp/ulreq/ulreq_test.go index 2c5e85a..06963ff 100644 --- a/formats/packp/ulreq/ulreq_test.go +++ b/plumbing/format/packp/ulreq/ulreq_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp/pktline" . "gopkg.in/check.v1" ) @@ -20,17 +20,17 @@ func ExampleEncoder_Encode() { ur := New() // Add a couple of wants - ur.Wants = append(ur.Wants, core.NewHash("3333333333333333333333333333333333333333")) - ur.Wants = append(ur.Wants, core.NewHash("1111111111111111111111111111111111111111")) - ur.Wants = append(ur.Wants, core.NewHash("2222222222222222222222222222222222222222")) + ur.Wants = append(ur.Wants, plumbing.NewHash("3333333333333333333333333333333333333333")) + ur.Wants = append(ur.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) + ur.Wants = append(ur.Wants, plumbing.NewHash("2222222222222222222222222222222222222222")) // And some capabilities you will like the server to use ur.Capabilities.Add("sysref", "HEAD:/refs/heads/master") ur.Capabilities.Add("ofs-delta") // Add a couple of shallows - ur.Shallows = append(ur.Shallows, core.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) - ur.Shallows = append(ur.Shallows, core.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) + ur.Shallows = append(ur.Shallows, plumbing.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) + ur.Shallows = append(ur.Shallows, plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) // And retrict the answer of the server to commits newer than "2015-01-02 03:04:05 UTC" since := time.Date(2015, time.January, 2, 3, 4, 5, 0, time.UTC) diff --git a/core/hash.go b/plumbing/hash.go index c50ffb2..7fa953d 100644 --- a/core/hash.go +++ b/plumbing/hash.go @@ -1,4 +1,4 @@ -package core +package plumbing import ( "crypto/sha1" diff --git a/core/hash_test.go b/plumbing/hash_test.go index 782777e..370811e 100644 --- a/core/hash_test.go +++ b/plumbing/hash_test.go @@ -1,4 +1,4 @@ -package core +package plumbing import ( "testing" diff --git a/core/memory.go b/plumbing/memory.go index dabee3a..c65ce1f 100644 --- a/core/memory.go +++ b/plumbing/memory.go @@ -1,4 +1,4 @@ -package core +package plumbing import ( "bytes" diff --git a/core/memory_test.go b/plumbing/memory_test.go index f1c3f64..879ed37 100644 --- a/core/memory_test.go +++ b/plumbing/memory_test.go @@ -1,4 +1,4 @@ -package core +package plumbing import ( "io/ioutil" diff --git a/plumbing/object.go b/plumbing/object.go new file mode 100644 index 0000000..23abd4f --- /dev/null +++ b/plumbing/object.go @@ -0,0 +1,94 @@ +// package plumbing implement the core interfaces and structs used by go-git +package plumbing + +import ( + "errors" + "io" +) + +var ( + ErrObjectNotFound = errors.New("object not found") + // ErrInvalidType is returned when an invalid object type is provided. + ErrInvalidType = errors.New("invalid object type") +) + +// Object is a generic representation of any git object +type Object interface { + Hash() Hash + Type() ObjectType + SetType(ObjectType) + Size() int64 + SetSize(int64) + Reader() (io.ReadCloser, error) + Writer() (io.WriteCloser, error) +} + +// ObjectType internal object type +// Integer values from 0 to 7 map to those exposed by git. +// AnyObject is used to represent any from 0 to 7. +type ObjectType int8 + +const ( + InvalidObject ObjectType = 0 + CommitObject ObjectType = 1 + TreeObject ObjectType = 2 + BlobObject ObjectType = 3 + TagObject ObjectType = 4 + // 5 reserved for future expansion + OFSDeltaObject ObjectType = 6 + REFDeltaObject ObjectType = 7 + + AnyObject ObjectType = -127 +) + +func (t ObjectType) String() string { + switch t { + case CommitObject: + return "commit" + case TreeObject: + return "tree" + case BlobObject: + return "blob" + case TagObject: + return "tag" + case OFSDeltaObject: + return "ofs-delta" + case REFDeltaObject: + return "ref-delta" + case AnyObject: + return "any" + default: + return "unknown" + } +} + +func (t ObjectType) Bytes() []byte { + return []byte(t.String()) +} + +// Valid returns true if t is a valid ObjectType. +func (t ObjectType) Valid() bool { + return t >= CommitObject && t <= REFDeltaObject +} + +// ParseObjectType parses a string representation of ObjectType. It returns an +// error on parse failure. +func ParseObjectType(value string) (typ ObjectType, err error) { + switch value { + case "commit": + typ = CommitObject + case "tree": + typ = TreeObject + case "blob": + typ = BlobObject + case "tag": + typ = TagObject + case "ofs-delta": + typ = OFSDeltaObject + case "ref-delta": + typ = REFDeltaObject + default: + err = ErrInvalidType + } + return +} diff --git a/plumbing/object_test.go b/plumbing/object_test.go new file mode 100644 index 0000000..4d2dbe2 --- /dev/null +++ b/plumbing/object_test.go @@ -0,0 +1,46 @@ +package plumbing + +import . "gopkg.in/check.v1" + +type ObjectSuite struct{} + +var _ = Suite(&ObjectSuite{}) + +func (s *ObjectSuite) TestObjectTypeString(c *C) { + c.Assert(CommitObject.String(), Equals, "commit") + c.Assert(TreeObject.String(), Equals, "tree") + c.Assert(BlobObject.String(), Equals, "blob") + c.Assert(TagObject.String(), Equals, "tag") + c.Assert(REFDeltaObject.String(), Equals, "ref-delta") + c.Assert(OFSDeltaObject.String(), Equals, "ofs-delta") + c.Assert(AnyObject.String(), Equals, "any") + c.Assert(ObjectType(42).String(), Equals, "unknown") +} + +func (s *ObjectSuite) TestObjectTypeBytes(c *C) { + c.Assert(CommitObject.Bytes(), DeepEquals, []byte("commit")) +} + +func (s *ObjectSuite) TestObjectTypeValid(c *C) { + c.Assert(CommitObject.Valid(), Equals, true) + c.Assert(ObjectType(42).Valid(), Equals, false) +} + +func (s *ObjectSuite) TestParseObjectType(c *C) { + for s, e := range map[string]ObjectType{ + "commit": CommitObject, + "tree": TreeObject, + "blob": BlobObject, + "tag": TagObject, + "ref-delta": REFDeltaObject, + "ofs-delta": OFSDeltaObject, + } { + t, err := ParseObjectType(s) + c.Assert(err, IsNil) + c.Assert(e, Equals, t) + } + + t, err := ParseObjectType("foo") + c.Assert(err, Equals, ErrInvalidType) + c.Assert(t, Equals, InvalidObject) +} diff --git a/core/reference.go b/plumbing/reference.go index ee55a6a..98516c7 100644 --- a/core/reference.go +++ b/plumbing/reference.go @@ -1,9 +1,8 @@ -package core +package plumbing import ( "errors" "fmt" - "io" "strings" ) @@ -14,13 +13,10 @@ const ( refRemotePrefix = refPrefix + "remotes/" refNotePrefix = refPrefix + "notes/" symrefPrefix = "ref: " - - maxResolveRecursion = 1024 ) var ( - ErrMaxResolveRecursion = errors.New("max. recursion level reached") - ErrReferenceNotFound = errors.New("reference not found") + ErrReferenceNotFound = errors.New("reference not found") ) // ReferenceType reference type's @@ -148,83 +144,3 @@ func (r *Reference) String() string { s := r.Strings() return fmt.Sprintf("%s %s", s[1], s[0]) } - -// ReferenceSliceIter implements ReferenceIter. It iterates over a series of -// references stored in a slice and yields each one in turn when Next() is -// called. -// -// The ReferenceSliceIter must be closed with a call to Close() when it is no -// longer needed. -type ReferenceSliceIter struct { - series []*Reference - pos int -} - -// NewReferenceSliceIter returns a reference iterator for the given slice of -// objects. -func NewReferenceSliceIter(series []*Reference) *ReferenceSliceIter { - return &ReferenceSliceIter{ - series: series, - } -} - -// Next returns the next reference from the iterator. If the iterator has -// reached the end it will return io.EOF as an error. -func (iter *ReferenceSliceIter) Next() (*Reference, error) { - if iter.pos >= len(iter.series) { - return nil, io.EOF - } - - obj := iter.series[iter.pos] - iter.pos++ - return obj, nil -} - -// ForEach call the cb function for each reference contained on this iter until -// an error happends or the end of the iter is reached. If ErrStop is sent -// the iteration is stop but no error is returned. The iterator is closed. -func (iter *ReferenceSliceIter) ForEach(cb func(*Reference) error) error { - defer iter.Close() - for _, r := range iter.series { - if err := cb(r); err != nil { - if err == ErrStop { - return nil - } - - return nil - } - } - - return nil -} - -// Close releases any resources used by the iterator. -func (iter *ReferenceSliceIter) Close() { - iter.pos = len(iter.series) -} - -func ResolveReference(s ReferenceStorer, n ReferenceName) (*Reference, error) { - r, err := s.Reference(n) - if err != nil || r == nil { - return r, err - } - return resolveReference(s, r, 0) -} - -func resolveReference(s ReferenceStorer, r *Reference, recursion int) (*Reference, error) { - if r.Type() != SymbolicReference { - return r, nil - } - - if recursion > maxResolveRecursion { - return nil, ErrMaxResolveRecursion - } - - t, err := s.Reference(r.Target()) - if err != nil { - return nil, err - } - - recursion++ - return resolveReference(s, t, recursion) -} diff --git a/core/reference_test.go b/plumbing/reference_test.go index b14f24c..4d9b393 100644 --- a/core/reference_test.go +++ b/plumbing/reference_test.go @@ -1,10 +1,6 @@ -package core +package plumbing -import ( - "io" - - . "gopkg.in/check.v1" -) +import . "gopkg.in/check.v1" type ReferenceSuite struct{} @@ -63,58 +59,3 @@ func (s *ReferenceSuite) TestIsTag(c *C) { r := NewHashReference(ReferenceName("refs/tags/v3.1."), ZeroHash) c.Assert(r.IsTag(), Equals, true) } - -func (s *ReferenceSuite) TestReferenceSliceIterNext(c *C) { - slice := []*Reference{ - NewReferenceFromStrings("foo", "foo"), - NewReferenceFromStrings("bar", "bar"), - } - - i := NewReferenceSliceIter(slice) - foo, err := i.Next() - c.Assert(err, IsNil) - c.Assert(foo == slice[0], Equals, true) - - bar, err := i.Next() - c.Assert(err, IsNil) - c.Assert(bar == slice[1], Equals, true) - - empty, err := i.Next() - c.Assert(err, Equals, io.EOF) - c.Assert(empty, IsNil) -} - -func (s *ReferenceSuite) TestReferenceSliceIterForEach(c *C) { - slice := []*Reference{ - NewReferenceFromStrings("foo", "foo"), - NewReferenceFromStrings("bar", "bar"), - } - - i := NewReferenceSliceIter(slice) - var count int - i.ForEach(func(r *Reference) error { - c.Assert(r == slice[count], Equals, true) - count++ - return nil - }) - - c.Assert(count, Equals, 2) -} - -func (s *ReferenceSuite) TestReferenceSliceIterForEachStop(c *C) { - slice := []*Reference{ - NewReferenceFromStrings("foo", "foo"), - NewReferenceFromStrings("bar", "bar"), - } - - i := NewReferenceSliceIter(slice) - - var count int - i.ForEach(func(r *Reference) error { - c.Assert(r == slice[count], Equals, true) - count++ - return ErrStop - }) - - c.Assert(count, Equals, 1) -} diff --git a/plumbing/storer/index.go b/plumbing/storer/index.go new file mode 100644 index 0000000..e087296 --- /dev/null +++ b/plumbing/storer/index.go @@ -0,0 +1,9 @@ +package storer + +import "gopkg.in/src-d/go-git.v4/plumbing/format/index" + +// IndexStorer generic storage of index.Index +type IndexStorer interface { + SetIndex(*index.Index) error + Index() (*index.Index, error) +} diff --git a/core/object.go b/plumbing/storer/object.go index 8125465..c7841b6 100644 --- a/core/object.go +++ b/plumbing/storer/object.go @@ -1,96 +1,71 @@ -// Package core implement the core interfaces and structs used by go-git -package core +package storer import ( "errors" "io" -) -var ( - ErrObjectNotFound = errors.New("object not found") - // ErrInvalidType is returned when an invalid object type is provided. - ErrInvalidType = errors.New("invalid object type") + "gopkg.in/src-d/go-git.v4/plumbing" ) -// Object is a generic representation of any git object -type Object interface { - Hash() Hash - Type() ObjectType - SetType(ObjectType) - Size() int64 - SetSize(int64) - Reader() (io.ReadCloser, error) - Writer() (io.WriteCloser, error) -} - -// ObjectType internal object type -// Integer values from 0 to 7 map to those exposed by git. -// AnyObject is used to represent any from 0 to 7. -type ObjectType int8 - -const ( - InvalidObject ObjectType = 0 - CommitObject ObjectType = 1 - TreeObject ObjectType = 2 - BlobObject ObjectType = 3 - TagObject ObjectType = 4 - // 5 reserved for future expansion - OFSDeltaObject ObjectType = 6 - REFDeltaObject ObjectType = 7 - - AnyObject ObjectType = -127 +var ( + //ErrStop is used to stop a ForEach function in an Iter + ErrStop = errors.New("stop iter") ) -func (t ObjectType) String() string { - switch t { - case CommitObject: - return "commit" - case TreeObject: - return "tree" - case BlobObject: - return "blob" - case TagObject: - return "tag" - case OFSDeltaObject: - return "ofs-delta" - case REFDeltaObject: - return "ref-delta" - case AnyObject: - return "any" - default: - return "unknown" - } -} - -func (t ObjectType) Bytes() []byte { - return []byte(t.String()) -} - -// Valid returns true if t is a valid ObjectType. -func (t ObjectType) Valid() bool { - return t >= CommitObject && t <= REFDeltaObject +// ObjectStorer generic storage of objects +type ObjectStorer interface { + // NewObject returns a new plumbing.Object, the real type of the object can + // be a custom implementation or the defaul one, plumbing.MemoryObject + NewObject() plumbing.Object + // SetObject save an object into the storage, the object shuld be create + // with the NewObject, method, and file if the type is not supported. + SetObject(plumbing.Object) (plumbing.Hash, error) + // Object get an object by hash with the given plumbing.ObjectType. + // Implementors should return (nil, plumbing.ErrObjectNotFound) if an object + // doesn't exist with both the given hash and object type. + // + // Valid plumbing.ObjectType values are CommitObject, BlobObject, TagObject, + // TreeObject and AnyObject. If plumbing.AnyObject is given, the object must + // be looked up regardless of its type. + Object(plumbing.ObjectType, plumbing.Hash) (plumbing.Object, error) + // IterObjects returns a custom ObjectIter over all the object on the + // storage. + // + // Valid plumbing.ObjectType values are CommitObject, BlobObject, TagObject, + IterObjects(plumbing.ObjectType) (ObjectIter, error) +} + +// Transactioner is a optional method for ObjectStorer, it enable transaction +// base write and read operations in the storage +type Transactioner interface { + // Begin starts a transaction. + Begin() Transaction +} + +// PackfileWriter is a optional method for ObjectStorer, it enable direct write +// of packfile to the storage +type PackfileWriter interface { + // PackfileWriter retuns a writer for writing a packfile to the storage + // + // If the Storer not implements PackfileWriter the objects should be written + // using the Set method. + PackfileWriter() (io.WriteCloser, error) +} + +// ObjectIter is a generic closable interface for iterating over objects. +type ObjectIter interface { + Next() (plumbing.Object, error) + ForEach(func(plumbing.Object) error) error + Close() } -// ParseObjectType parses a string representation of ObjectType. It returns an -// error on parse failure. -func ParseObjectType(value string) (typ ObjectType, err error) { - switch value { - case "commit": - typ = CommitObject - case "tree": - typ = TreeObject - case "blob": - typ = BlobObject - case "tag": - typ = TagObject - case "ofs-delta": - typ = OFSDeltaObject - case "ref-delta": - typ = REFDeltaObject - default: - err = ErrInvalidType - } - return +// Transaction is an in-progress storage transaction. A transaction must end +// with a call to Commit or Rollback. +type Transaction interface { + SetObject(plumbing.Object) (plumbing.Hash, error) + Object(plumbing.ObjectType, plumbing.Hash) (plumbing.Object, error) + Commit() error + Rollback() error } // ObjectLookupIter implements ObjectIter. It iterates over a series of object @@ -102,14 +77,15 @@ func ParseObjectType(value string) (typ ObjectType, err error) { // longer needed. type ObjectLookupIter struct { storage ObjectStorer - series []Hash - t ObjectType + series []plumbing.Hash + t plumbing.ObjectType pos int } // NewObjectLookupIter returns an object iterator given an object storage and // a slice of object hashes. -func NewObjectLookupIter(storage ObjectStorer, t ObjectType, series []Hash) *ObjectLookupIter { +func NewObjectLookupIter( + storage ObjectStorer, t plumbing.ObjectType, series []plumbing.Hash) *ObjectLookupIter { return &ObjectLookupIter{ storage: storage, series: series, @@ -119,9 +95,9 @@ func NewObjectLookupIter(storage ObjectStorer, t ObjectType, series []Hash) *Obj // Next returns the next object from the iterator. If the iterator has reached // the end it will return io.EOF as an error. If the object can't be found in -// the object storage, it will return ErrObjectNotFound as an error. If the -// object is retreieved successfully error will be nil. -func (iter *ObjectLookupIter) Next() (Object, error) { +// the object storage, it will return plumbing.ErrObjectNotFound as an error. +// If the object is retreieved successfully error will be nil. +func (iter *ObjectLookupIter) Next() (plumbing.Object, error) { if iter.pos >= len(iter.series) { return nil, io.EOF } @@ -138,7 +114,7 @@ func (iter *ObjectLookupIter) Next() (Object, error) { // ForEach call the cb function for each object contained on this iter until // an error happends or the end of the iter is reached. If ErrStop is sent // the iteration is stop but no error is returned. The iterator is closed. -func (iter *ObjectLookupIter) ForEach(cb func(Object) error) error { +func (iter *ObjectLookupIter) ForEach(cb func(plumbing.Object) error) error { return ForEachIterator(iter, cb) } @@ -153,12 +129,12 @@ func (iter *ObjectLookupIter) Close() { // The ObjectSliceIter must be closed with a call to Close() when it is no // longer needed. type ObjectSliceIter struct { - series []Object + series []plumbing.Object pos int } // NewObjectSliceIter returns an object iterator for the given slice of objects. -func NewObjectSliceIter(series []Object) *ObjectSliceIter { +func NewObjectSliceIter(series []plumbing.Object) *ObjectSliceIter { return &ObjectSliceIter{ series: series, } @@ -167,7 +143,7 @@ func NewObjectSliceIter(series []Object) *ObjectSliceIter { // Next returns the next object from the iterator. If the iterator has reached // the end it will return io.EOF as an error. If the object is retreieved // successfully error will be nil. -func (iter *ObjectSliceIter) Next() (Object, error) { +func (iter *ObjectSliceIter) Next() (plumbing.Object, error) { if len(iter.series) == 0 { return nil, io.EOF } @@ -181,13 +157,13 @@ func (iter *ObjectSliceIter) Next() (Object, error) { // ForEach call the cb function for each object contained on this iter until // an error happends or the end of the iter is reached. If ErrStop is sent // the iteration is stop but no error is returned. The iterator is closed. -func (iter *ObjectSliceIter) ForEach(cb func(Object) error) error { +func (iter *ObjectSliceIter) ForEach(cb func(plumbing.Object) error) error { return ForEachIterator(iter, cb) } // Close releases any resources used by the iterator. func (iter *ObjectSliceIter) Close() { - iter.series = []Object{} + iter.series = []plumbing.Object{} } // MultiObjectIter implements ObjectIter. It iterates over several ObjectIter, @@ -206,7 +182,7 @@ func NewMultiObjectIter(iters []ObjectIter) ObjectIter { // Next returns the next object from the iterator, if one iterator reach io.EOF // is removed and the next one is used. -func (iter *MultiObjectIter) Next() (Object, error) { +func (iter *MultiObjectIter) Next() (plumbing.Object, error) { if len(iter.iters) == 0 { return nil, io.EOF } @@ -224,7 +200,7 @@ func (iter *MultiObjectIter) Next() (Object, error) { // ForEach call the cb function for each object contained on this iter until // an error happends or the end of the iter is reached. If ErrStop is sent // the iteration is stop but no error is returned. The iterator is closed. -func (iter *MultiObjectIter) ForEach(cb func(Object) error) error { +func (iter *MultiObjectIter) ForEach(cb func(plumbing.Object) error) error { return ForEachIterator(iter, cb) } @@ -236,13 +212,13 @@ func (iter *MultiObjectIter) Close() { } type bareIterator interface { - Next() (Object, error) + Next() (plumbing.Object, error) Close() } // ForEachIterator is a helper function to build iterators without need to // rewrite the same ForEach function each time. -func ForEachIterator(iter bareIterator, cb func(Object) error) error { +func ForEachIterator(iter bareIterator, cb func(plumbing.Object) error) error { defer iter.Close() for { obj, err := iter.Next() diff --git a/plumbing/storer/object_test.go b/plumbing/storer/object_test.go new file mode 100644 index 0000000..a0a7755 --- /dev/null +++ b/plumbing/storer/object_test.go @@ -0,0 +1,150 @@ +package storer + +import ( + "fmt" + "testing" + + . "gopkg.in/check.v1" + "gopkg.in/src-d/go-git.v4/plumbing" +) + +func Test(t *testing.T) { TestingT(t) } + +type ObjectSuite struct { + Objects []plumbing.Object + Hash []plumbing.Hash +} + +var _ = Suite(&ObjectSuite{}) + +func (s *ObjectSuite) SetUpSuite(c *C) { + s.Objects = []plumbing.Object{ + s.buildObject([]byte("foo")), + s.buildObject([]byte("bar")), + } + + for _, o := range s.Objects { + s.Hash = append(s.Hash, o.Hash()) + } +} + +func (s *ObjectSuite) TestMultiObjectIterNext(c *C) { + expected := []plumbing.Object{ + &plumbing.MemoryObject{}, + &plumbing.MemoryObject{}, + &plumbing.MemoryObject{}, + &plumbing.MemoryObject{}, + &plumbing.MemoryObject{}, + &plumbing.MemoryObject{}, + } + + iter := NewMultiObjectIter([]ObjectIter{ + NewObjectSliceIter(expected[0:2]), + NewObjectSliceIter(expected[2:4]), + NewObjectSliceIter(expected[4:5]), + }) + + var i int + iter.ForEach(func(o plumbing.Object) error { + c.Assert(o, Equals, expected[i]) + i++ + return nil + }) + + iter.Close() +} + +func (s *ObjectSuite) buildObject(content []byte) plumbing.Object { + o := &plumbing.MemoryObject{} + o.Write(content) + + return o +} + +func (s *ObjectSuite) TestObjectLookupIter(c *C) { + var count int + + storage := &MockObjectStorage{s.Objects} + i := NewObjectLookupIter(storage, plumbing.CommitObject, s.Hash) + err := i.ForEach(func(o plumbing.Object) error { + c.Assert(o, NotNil) + c.Assert(o.Hash().String(), Equals, s.Hash[count].String()) + count++ + return nil + }) + + c.Assert(err, IsNil) + i.Close() +} + +func (s *ObjectSuite) TestObjectSliceIter(c *C) { + var count int + + i := NewObjectSliceIter(s.Objects) + err := i.ForEach(func(o plumbing.Object) error { + c.Assert(o, NotNil) + c.Assert(o.Hash().String(), Equals, s.Hash[count].String()) + count++ + return nil + }) + + c.Assert(count, Equals, 2) + c.Assert(err, IsNil) + c.Assert(i.series, HasLen, 0) +} + +func (s *ObjectSuite) TestObjectSliceIterStop(c *C) { + i := NewObjectSliceIter(s.Objects) + + var count = 0 + err := i.ForEach(func(o plumbing.Object) error { + c.Assert(o, NotNil) + c.Assert(o.Hash().String(), Equals, s.Hash[count].String()) + count++ + return ErrStop + }) + + c.Assert(count, Equals, 1) + c.Assert(err, IsNil) +} + +func (s *ObjectSuite) TestObjectSliceIterError(c *C) { + i := NewObjectSliceIter([]plumbing.Object{ + s.buildObject([]byte("foo")), + }) + + err := i.ForEach(func(plumbing.Object) error { + return fmt.Errorf("a random error") + }) + + c.Assert(err, NotNil) +} + +type MockObjectStorage struct { + db []plumbing.Object +} + +func (o *MockObjectStorage) NewObject() plumbing.Object { + return nil +} + +func (o *MockObjectStorage) SetObject(obj plumbing.Object) (plumbing.Hash, error) { + return plumbing.ZeroHash, nil +} + +func (o *MockObjectStorage) Object(t plumbing.ObjectType, h plumbing.Hash) (plumbing.Object, error) { + for _, o := range o.db { + if o.Hash() == h { + return o, nil + } + } + return nil, plumbing.ErrObjectNotFound +} + +func (o *MockObjectStorage) IterObjects(t plumbing.ObjectType) (ObjectIter, error) { + return nil, nil +} + +func (o *MockObjectStorage) Begin() Transaction { + return nil +} diff --git a/plumbing/storer/reference.go b/plumbing/storer/reference.go new file mode 100644 index 0000000..5e818c6 --- /dev/null +++ b/plumbing/storer/reference.go @@ -0,0 +1,109 @@ +package storer + +import ( + "errors" + "io" + + "gopkg.in/src-d/go-git.v4/plumbing" +) + +const MaxResolveRecursion = 1024 + +// ErrMaxResolveRecursion is returned by ResolveReference is MaxResolveRecursion +// is exceeded +var ErrMaxResolveRecursion = errors.New("max. recursion level reached") + +// ReferenceStorer generic storage of references +type ReferenceStorer interface { + SetReference(*plumbing.Reference) error + Reference(plumbing.ReferenceName) (*plumbing.Reference, error) + IterReferences() (ReferenceIter, error) +} + +// ReferenceIter is a generic closable interface for iterating over references +type ReferenceIter interface { + Next() (*plumbing.Reference, error) + ForEach(func(*plumbing.Reference) error) error + Close() +} + +// ReferenceSliceIter implements ReferenceIter. It iterates over a series of +// references stored in a slice and yields each one in turn when Next() is +// called. +// +// The ReferenceSliceIter must be closed with a call to Close() when it is no +// longer needed. +type ReferenceSliceIter struct { + series []*plumbing.Reference + pos int +} + +// NewReferenceSliceIter returns a reference iterator for the given slice of +// objects. +func NewReferenceSliceIter(series []*plumbing.Reference) *ReferenceSliceIter { + return &ReferenceSliceIter{ + series: series, + } +} + +// Next returns the next reference from the iterator. If the iterator has +// reached the end it will return io.EOF as an error. +func (iter *ReferenceSliceIter) Next() (*plumbing.Reference, error) { + if iter.pos >= len(iter.series) { + return nil, io.EOF + } + + obj := iter.series[iter.pos] + iter.pos++ + return obj, nil +} + +// ForEach call the cb function for each reference contained on this iter until +// an error happends or the end of the iter is reached. If ErrStop is sent +// the iteration is stop but no error is returned. The iterator is closed. +func (iter *ReferenceSliceIter) ForEach(cb func(*plumbing.Reference) error) error { + defer iter.Close() + for _, r := range iter.series { + if err := cb(r); err != nil { + if err == ErrStop { + return nil + } + + return nil + } + } + + return nil +} + +// Close releases any resources used by the iterator. +func (iter *ReferenceSliceIter) Close() { + iter.pos = len(iter.series) +} + +// ResolveReference resolve a SymbolicReference to a HashReference +func ResolveReference(s ReferenceStorer, n plumbing.ReferenceName) (*plumbing.Reference, error) { + r, err := s.Reference(n) + if err != nil || r == nil { + return r, err + } + return resolveReference(s, r, 0) +} + +func resolveReference(s ReferenceStorer, r *plumbing.Reference, recursion int) (*plumbing.Reference, error) { + if r.Type() != plumbing.SymbolicReference { + return r, nil + } + + if recursion > MaxResolveRecursion { + return nil, ErrMaxResolveRecursion + } + + t, err := s.Reference(r.Target()) + if err != nil { + return nil, err + } + + recursion++ + return resolveReference(s, t, recursion) +} diff --git a/plumbing/storer/reference_test.go b/plumbing/storer/reference_test.go new file mode 100644 index 0000000..3014df5 --- /dev/null +++ b/plumbing/storer/reference_test.go @@ -0,0 +1,67 @@ +package storer + +import ( + "io" + + . "gopkg.in/check.v1" + "gopkg.in/src-d/go-git.v4/plumbing" +) + +type ReferenceSuite struct{} + +var _ = Suite(&ReferenceSuite{}) + +func (s *ReferenceSuite) TestReferenceSliceIterNext(c *C) { + slice := []*plumbing.Reference{ + plumbing.NewReferenceFromStrings("foo", "foo"), + plumbing.NewReferenceFromStrings("bar", "bar"), + } + + i := NewReferenceSliceIter(slice) + foo, err := i.Next() + c.Assert(err, IsNil) + c.Assert(foo == slice[0], Equals, true) + + bar, err := i.Next() + c.Assert(err, IsNil) + c.Assert(bar == slice[1], Equals, true) + + empty, err := i.Next() + c.Assert(err, Equals, io.EOF) + c.Assert(empty, IsNil) +} + +func (s *ReferenceSuite) TestReferenceSliceIterForEach(c *C) { + slice := []*plumbing.Reference{ + plumbing.NewReferenceFromStrings("foo", "foo"), + plumbing.NewReferenceFromStrings("bar", "bar"), + } + + i := NewReferenceSliceIter(slice) + var count int + i.ForEach(func(r *plumbing.Reference) error { + c.Assert(r == slice[count], Equals, true) + count++ + return nil + }) + + c.Assert(count, Equals, 2) +} + +func (s *ReferenceSuite) TestReferenceSliceIterForEachStop(c *C) { + slice := []*plumbing.Reference{ + plumbing.NewReferenceFromStrings("foo", "foo"), + plumbing.NewReferenceFromStrings("bar", "bar"), + } + + i := NewReferenceSliceIter(slice) + + var count int + i.ForEach(func(r *plumbing.Reference) error { + c.Assert(r == slice[count], Equals, true) + count++ + return ErrStop + }) + + c.Assert(count, Equals, 1) +} diff --git a/references.go b/references.go index 7590560..0ce7ea6 100644 --- a/references.go +++ b/references.go @@ -3,8 +3,8 @@ package git import ( "io" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/diff" + "gopkg.in/src-d/go-git.v4/plumbing" "github.com/sergi/go-diff/diffmatchpatch" ) @@ -20,7 +20,7 @@ import ( // (see git path-id for hints on how to fix this). func (c *Commit) References(path string) ([]*Commit, error) { var result []*Commit - seen := make(map[core.Hash]struct{}, 0) + seen := make(map[plumbing.Hash]struct{}, 0) if err := walkGraph(&result, &seen, c.r, c, path); err != nil { return nil, err } @@ -33,7 +33,7 @@ func (c *Commit) References(path string) ([]*Commit, error) { // Recursive traversal of the commit graph, generating a linear history // of the path. -func walkGraph(result *[]*Commit, seen *map[core.Hash]struct{}, repo *Repository, current *Commit, path string) error { +func walkGraph(result *[]*Commit, seen *map[plumbing.Hash]struct{}, repo *Repository, current *Commit, path string) error { // check and update seen if _, ok := (*seen)[current.Hash]; ok { return nil @@ -117,10 +117,10 @@ func differentContents(path string, c *Commit, cs []*Commit) ([]*Commit, error) } // blobHash returns the hash of a path in a commit -func blobHash(path string, commit *Commit) (hash core.Hash, found bool) { +func blobHash(path string, commit *Commit) (hash plumbing.Hash, found bool) { file, err := commit.File(path) if err != nil { - var empty core.Hash + var empty plumbing.Hash return empty, found } return file.Hash, true diff --git a/references_test.go b/references_test.go index 112fe3a..f5a2fdc 100644 --- a/references_test.go +++ b/references_test.go @@ -4,8 +4,8 @@ import ( "bytes" "fmt" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" + "gopkg.in/src-d/go-git.v4/plumbing" . "gopkg.in/check.v1" ) @@ -296,7 +296,7 @@ func (s *ReferencesSuite) TestRevList(c *C) { repo, ok := s.Repositories[t.repo] c.Assert(ok, Equals, true) - commit, err := repo.Commit(core.NewHash(t.commit)) + commit, err := repo.Commit(plumbing.NewHash(t.commit)) c.Assert(err, IsNil) revs, err := commit.References(t.path) @@ -305,7 +305,7 @@ func (s *ReferencesSuite) TestRevList(c *C) { for i := range revs { if revs[i].Hash.String() != t.revs[i] { - commit, err := repo.Commit(core.NewHash(t.revs[i])) + commit, err := repo.Commit(plumbing.NewHash(t.revs[i])) c.Assert(err, IsNil) equiv, err := equivalent(t.path, revs[i], commit) c.Assert(err, IsNil) @@ -363,7 +363,7 @@ func (s *ReferencesSuite) commits(cc *C, repo string, hs ...string) []*Commit { cc.Assert(ok, Equals, true) result := make([]*Commit, 0, len(hs)) for _, h := range hs { - c, err := r.Commit(core.NewHash(h)) + c, err := r.Commit(plumbing.NewHash(h)) cc.Assert(err, IsNil) result = append(result, c) } @@ -5,12 +5,13 @@ import ( "fmt" "io" - "gopkg.in/src-d/go-git.v4/clients" - "gopkg.in/src-d/go-git.v4/clients/common" "gopkg.in/src-d/go-git.v4/config" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packfile" - "gopkg.in/src-d/go-git.v4/formats/packp" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/client" + "gopkg.in/src-d/go-git.v4/plumbing/client/common" + "gopkg.in/src-d/go-git.v4/plumbing/format/packfile" + "gopkg.in/src-d/go-git.v4/plumbing/format/packp" + "gopkg.in/src-d/go-git.v4/plumbing/storer" ) var NoErrAlreadyUpToDate = errors.New("already up-to-date") @@ -113,8 +114,8 @@ func (r *Remote) Fetch(o *FetchOptions) (err error) { return r.updateLocalReferenceStorage(o.RefSpecs, refs) } -func (r *Remote) getWantedReferences(spec []config.RefSpec) ([]*core.Reference, error) { - var refs []*core.Reference +func (r *Remote) getWantedReferences(spec []config.RefSpec) ([]*plumbing.Reference, error) { + var refs []*plumbing.Reference iter, err := r.Refs() if err != nil { return refs, err @@ -128,8 +129,8 @@ func (r *Remote) getWantedReferences(spec []config.RefSpec) ([]*core.Reference, } } - return refs, iter.ForEach(func(ref *core.Reference) error { - if ref.Type() != core.HashReference { + return refs, iter.ForEach(func(ref *plumbing.Reference) error { + if ref.Type() != plumbing.HashReference { return nil } @@ -139,8 +140,8 @@ func (r *Remote) getWantedReferences(spec []config.RefSpec) ([]*core.Reference, } } - _, err := r.s.Object(core.CommitObject, ref.Hash()) - if err == core.ErrObjectNotFound { + _, err := r.s.Object(plumbing.CommitObject, ref.Hash()) + if err == plumbing.ErrObjectNotFound { refs = append(refs, ref) return nil } @@ -150,7 +151,7 @@ func (r *Remote) getWantedReferences(spec []config.RefSpec) ([]*core.Reference, } func (r *Remote) buildRequest( - s core.ReferenceStorer, o *FetchOptions, refs []*core.Reference, + s storer.ReferenceStorer, o *FetchOptions, refs []*plumbing.Reference, ) (*common.GitUploadPackRequest, error) { req := &common.GitUploadPackRequest{} req.Depth = o.Depth @@ -164,8 +165,8 @@ func (r *Remote) buildRequest( return nil, err } - err = i.ForEach(func(ref *core.Reference) error { - if ref.Type() != core.HashReference { + err = i.ForEach(func(ref *plumbing.Reference) error { + if ref.Type() != plumbing.HashReference { return nil } @@ -177,7 +178,7 @@ func (r *Remote) buildRequest( } func (r *Remote) updateObjectStorage(reader io.Reader) error { - if sw, ok := r.s.(core.PackfileWriter); ok { + if sw, ok := r.s.(storer.PackfileWriter); ok { w, err := sw.PackfileWriter() if err != nil { return err @@ -198,19 +199,19 @@ func (r *Remote) updateObjectStorage(reader io.Reader) error { return err } -func (r *Remote) updateLocalReferenceStorage(specs []config.RefSpec, refs []*core.Reference) error { +func (r *Remote) updateLocalReferenceStorage(specs []config.RefSpec, refs []*plumbing.Reference) error { for _, spec := range specs { for _, ref := range refs { if !spec.Match(ref.Name()) { continue } - if ref.Type() != core.HashReference { + if ref.Type() != plumbing.HashReference { continue } name := spec.Dst(ref.Name()) - n := core.NewHashReference(name, ref.Hash()) + n := plumbing.NewHashReference(name, ref.Hash()) if err := r.s.SetReference(n); err != nil { return err } @@ -226,13 +227,13 @@ func (r *Remote) buildFetchedTags() error { return err } - return iter.ForEach(func(ref *core.Reference) error { + return iter.ForEach(func(ref *plumbing.Reference) error { if !ref.IsTag() { return nil } - _, err := r.s.Object(core.AnyObject, ref.Hash()) - if err == core.ErrObjectNotFound { + _, err := r.s.Object(plumbing.AnyObject, ref.Hash()) + if err == plumbing.ErrObjectNotFound { return nil } @@ -245,21 +246,21 @@ func (r *Remote) buildFetchedTags() error { } // Head returns the Reference of the HEAD -func (r *Remote) Head() *core.Reference { +func (r *Remote) Head() *plumbing.Reference { return r.upInfo.Head() } // Ref returns the Hash pointing the given refName -func (r *Remote) Ref(name core.ReferenceName, resolved bool) (*core.Reference, error) { +func (r *Remote) Ref(name plumbing.ReferenceName, resolved bool) (*plumbing.Reference, error) { if resolved { - return core.ResolveReference(r.upInfo.Refs, name) + return storer.ResolveReference(r.upInfo.Refs, name) } return r.upInfo.Refs.Reference(name) } // Refs returns a map with all the References -func (r *Remote) Refs() (core.ReferenceIter, error) { +func (r *Remote) Refs() (storer.ReferenceIter, error) { return r.upInfo.Refs.IterReferences() } diff --git a/remote_test.go b/remote_test.go index 04167cd..f129c68 100644 --- a/remote_test.go +++ b/remote_test.go @@ -6,7 +6,8 @@ import ( "os" "gopkg.in/src-d/go-git.v4/config" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" "gopkg.in/src-d/go-git.v4/storage/filesystem" "gopkg.in/src-d/go-git.v4/storage/memory" osfs "gopkg.in/src-d/go-git.v4/utils/fs/os" @@ -58,7 +59,7 @@ func (s *RemoteSuite) TestDefaultBranch(c *C) { r.upSrv = &MockGitUploadPackService{} c.Assert(r.Connect(), IsNil) - c.Assert(r.Head().Name(), Equals, core.ReferenceName("refs/heads/master")) + c.Assert(r.Head().Name(), Equals, plumbing.ReferenceName("refs/heads/master")) } func (s *RemoteSuite) TestCapabilities(c *C) { @@ -83,10 +84,10 @@ func (s *RemoteSuite) TestFetch(c *C) { c.Assert(err, IsNil) c.Assert(sto.Objects, HasLen, 31) - expectedRefs := []*core.Reference{ - core.NewReferenceFromStrings("refs/remotes/origin/master", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), - core.NewReferenceFromStrings("refs/remotes/origin/branch", "e8d3ffab552895c19b9fcf7aa264d277cde33881"), - core.NewReferenceFromStrings("refs/tags/v1.0.0", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), + expectedRefs := []*plumbing.Reference{ + plumbing.NewReferenceFromStrings("refs/remotes/origin/master", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), + plumbing.NewReferenceFromStrings("refs/remotes/origin/branch", "e8d3ffab552895c19b9fcf7aa264d277cde33881"), + plumbing.NewReferenceFromStrings("refs/tags/v1.0.0", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), } for _, exp := range expectedRefs { @@ -102,7 +103,7 @@ type mockPackfileWriter struct { func (m *mockPackfileWriter) PackfileWriter() (io.WriteCloser, error) { m.PackfileWriterCalled = true - return m.Storer.(core.PackfileWriter).PackfileWriter() + return m.Storer.(storer.PackfileWriter).PackfileWriter() } func (s *RemoteSuite) TestFetchWithPackfileWriter(c *C) { @@ -128,10 +129,10 @@ func (s *RemoteSuite) TestFetchWithPackfileWriter(c *C) { c.Assert(err, IsNil) var count int - iter, err := mock.IterObjects(core.AnyObject) + iter, err := mock.IterObjects(plumbing.AnyObject) c.Assert(err, IsNil) - iter.ForEach(func(core.Object) error { + iter.ForEach(func(plumbing.Object) error { count++ return nil }) @@ -163,7 +164,7 @@ func (s *RemoteSuite) TestHead(c *C) { err := r.Connect() c.Assert(err, IsNil) - c.Assert(r.Head().Hash(), Equals, core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + c.Assert(r.Head().Hash(), Equals, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) } func (s *RemoteSuite) TestRef(c *C) { @@ -173,13 +174,13 @@ func (s *RemoteSuite) TestRef(c *C) { err := r.Connect() c.Assert(err, IsNil) - ref, err := r.Ref(core.HEAD, false) + ref, err := r.Ref(plumbing.HEAD, false) c.Assert(err, IsNil) - c.Assert(ref.Name(), Equals, core.HEAD) + c.Assert(ref.Name(), Equals, plumbing.HEAD) - ref, err = r.Ref(core.HEAD, true) + ref, err = r.Ref(plumbing.HEAD, true) c.Assert(err, IsNil) - c.Assert(ref.Name(), Equals, core.ReferenceName("refs/heads/master")) + c.Assert(ref.Name(), Equals, plumbing.ReferenceName("refs/heads/master")) } func (s *RemoteSuite) TestRefs(c *C) { diff --git a/repository.go b/repository.go index 899127b..ec3a1f9 100644 --- a/repository.go +++ b/repository.go @@ -5,7 +5,8 @@ import ( "fmt" "gopkg.in/src-d/go-git.v4/config" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" "gopkg.in/src-d/go-git.v4/storage/filesystem" "gopkg.in/src-d/go-git.v4/storage/memory" osfs "gopkg.in/src-d/go-git.v4/utils/fs/os" @@ -176,7 +177,7 @@ func (r *Repository) updateRemoteConfig( return nil } - head, err := core.ResolveReference(remote.Info().Refs, o.ReferenceName) + head, err := storer.ResolveReference(remote.Info().Refs, o.ReferenceName) if err != nil { return err } @@ -195,10 +196,10 @@ func (r *Repository) updateRemoteConfig( } -func (r *Repository) createReferences(ref *core.Reference) error { +func (r *Repository) createReferences(ref *plumbing.Reference) error { if !ref.IsBranch() { // detached HEAD mode - head := core.NewHashReference(core.HEAD, ref.Hash()) + head := plumbing.NewHashReference(plumbing.HEAD, ref.Hash()) return r.s.SetReference(head) } @@ -206,7 +207,7 @@ func (r *Repository) createReferences(ref *core.Reference) error { return err } - head := core.NewSymbolicReference(core.HEAD, ref.Name()) + head := plumbing.NewSymbolicReference(plumbing.HEAD, ref.Name()) return r.s.SetReference(head) } @@ -218,7 +219,7 @@ func (r *Repository) IsEmpty() (bool, error) { } var count int - return count == 0, iter.ForEach(func(r *core.Reference) error { + return count == 0, iter.ForEach(func(r *plumbing.Reference) error { count++ return nil }) @@ -264,8 +265,8 @@ func (r *Repository) Pull(o *PullOptions) error { } // Commit return the commit with the given hash -func (r *Repository) Commit(h core.Hash) (*Commit, error) { - commit, err := r.Object(core.CommitObject, h) +func (r *Repository) Commit(h plumbing.Hash) (*Commit, error) { + commit, err := r.Object(plumbing.CommitObject, h) if err != nil { return nil, err } @@ -275,7 +276,7 @@ func (r *Repository) Commit(h core.Hash) (*Commit, error) { // Commits decode the objects into commits func (r *Repository) Commits() (*CommitIter, error) { - iter, err := r.s.IterObjects(core.CommitObject) + iter, err := r.s.IterObjects(plumbing.CommitObject) if err != nil { return nil, err } @@ -284,8 +285,8 @@ func (r *Repository) Commits() (*CommitIter, error) { } // Tree return the tree with the given hash -func (r *Repository) Tree(h core.Hash) (*Tree, error) { - tree, err := r.Object(core.TreeObject, h) +func (r *Repository) Tree(h plumbing.Hash) (*Tree, error) { + tree, err := r.Object(plumbing.TreeObject, h) if err != nil { return nil, err } @@ -295,7 +296,7 @@ func (r *Repository) Tree(h core.Hash) (*Tree, error) { // Trees decodes the objects into trees func (r *Repository) Trees() (*TreeIter, error) { - iter, err := r.s.IterObjects(core.TreeObject) + iter, err := r.s.IterObjects(plumbing.TreeObject) if err != nil { return nil, err } @@ -304,8 +305,8 @@ func (r *Repository) Trees() (*TreeIter, error) { } // Blob returns the blob with the given hash -func (r *Repository) Blob(h core.Hash) (*Blob, error) { - blob, err := r.Object(core.BlobObject, h) +func (r *Repository) Blob(h plumbing.Hash) (*Blob, error) { + blob, err := r.Object(plumbing.BlobObject, h) if err != nil { return nil, err } @@ -315,7 +316,7 @@ func (r *Repository) Blob(h core.Hash) (*Blob, error) { // Blobs decodes the objects into blobs func (r *Repository) Blobs() (*BlobIter, error) { - iter, err := r.s.IterObjects(core.BlobObject) + iter, err := r.s.IterObjects(plumbing.BlobObject) if err != nil { return nil, err } @@ -324,8 +325,8 @@ func (r *Repository) Blobs() (*BlobIter, error) { } // Tag returns a tag with the given hash. -func (r *Repository) Tag(h core.Hash) (*Tag, error) { - tag, err := r.Object(core.TagObject, h) +func (r *Repository) Tag(h plumbing.Hash) (*Tag, error) { + tag, err := r.Object(plumbing.TagObject, h) if err != nil { return nil, err } @@ -336,7 +337,7 @@ func (r *Repository) Tag(h core.Hash) (*Tag, error) { // Tags returns a TagIter that can step through all of the annotated tags // in the repository. func (r *Repository) Tags() (*TagIter, error) { - iter, err := r.s.IterObjects(core.TagObject) + iter, err := r.s.IterObjects(plumbing.TagObject) if err != nil { return nil, err } @@ -345,37 +346,37 @@ func (r *Repository) Tags() (*TagIter, error) { } // Object returns an object with the given hash. -func (r *Repository) Object(t core.ObjectType, h core.Hash) (Object, error) { +func (r *Repository) Object(t plumbing.ObjectType, h plumbing.Hash) (Object, error) { obj, err := r.s.Object(t, h) if err != nil { - if err == core.ErrObjectNotFound { + if err == plumbing.ErrObjectNotFound { return nil, ErrObjectNotFound } return nil, err } switch obj.Type() { - case core.CommitObject: + case plumbing.CommitObject: commit := &Commit{r: r} return commit, commit.Decode(obj) - case core.TreeObject: + case plumbing.TreeObject: tree := &Tree{r: r} return tree, tree.Decode(obj) - case core.BlobObject: + case plumbing.BlobObject: blob := &Blob{} return blob, blob.Decode(obj) - case core.TagObject: + case plumbing.TagObject: tag := &Tag{r: r} return tag, tag.Decode(obj) default: - return nil, core.ErrInvalidType + return nil, plumbing.ErrInvalidType } } // Objects returns an ObjectIter that can step through all of the annotated tags // in the repository. func (r *Repository) Objects() (*ObjectIter, error) { - iter, err := r.s.IterObjects(core.AnyObject) + iter, err := r.s.IterObjects(plumbing.AnyObject) if err != nil { return nil, err } @@ -384,20 +385,20 @@ func (r *Repository) Objects() (*ObjectIter, error) { } // Head returns the reference where HEAD is pointing -func (r *Repository) Head() (*core.Reference, error) { - return core.ResolveReference(r.s, core.HEAD) +func (r *Repository) Head() (*plumbing.Reference, error) { + return storer.ResolveReference(r.s, plumbing.HEAD) } // Ref returns the Hash pointing the given refName -func (r *Repository) Ref(name core.ReferenceName, resolved bool) (*core.Reference, error) { +func (r *Repository) Ref(name plumbing.ReferenceName, resolved bool) (*plumbing.Reference, error) { if resolved { - return core.ResolveReference(r.s, name) + return storer.ResolveReference(r.s, name) } return r.s.Reference(name) } // Refs returns a map with all the References -func (r *Repository) Refs() (core.ReferenceIter, error) { +func (r *Repository) Refs() (storer.ReferenceIter, error) { return r.s.IterReferences() } diff --git a/repository_test.go b/repository_test.go index 6c7fe4f..dbcc232 100644 --- a/repository_test.go +++ b/repository_test.go @@ -2,7 +2,7 @@ package git import ( "gopkg.in/src-d/go-git.v4/config" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/storage/memory" . "gopkg.in/check.v1" @@ -64,7 +64,7 @@ func (s *RepositorySuite) TestClone(c *C) { r := NewMemoryRepository() head, err := r.Head() - c.Assert(err, Equals, core.ErrReferenceNotFound) + c.Assert(err, Equals, plumbing.ErrReferenceNotFound) c.Assert(head, IsNil) err = r.Clone(&CloneOptions{ @@ -77,10 +77,10 @@ func (s *RepositorySuite) TestClone(c *C) { c.Assert(err, IsNil) c.Assert(remotes, HasLen, 1) - head, err = r.Ref(core.HEAD, false) + head, err = r.Ref(plumbing.HEAD, false) c.Assert(err, IsNil) c.Assert(head, NotNil) - c.Assert(head.Type(), Equals, core.SymbolicReference) + c.Assert(head.Type(), Equals, plumbing.SymbolicReference) c.Assert(head.Target().String(), Equals, "refs/heads/master") branch, err := r.Ref(head.Target(), false) @@ -91,13 +91,13 @@ func (s *RepositorySuite) TestClone(c *C) { branch, err = r.Ref("refs/remotes/origin/master", false) c.Assert(err, IsNil) c.Assert(branch, NotNil) - c.Assert(branch.Type(), Equals, core.HashReference) + c.Assert(branch.Type(), Equals, plumbing.HashReference) c.Assert(branch.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5") branch, err = r.Ref("refs/remotes/origin/branch", false) c.Assert(err, IsNil) c.Assert(branch, NotNil) - c.Assert(branch.Type(), Equals, core.HashReference) + c.Assert(branch.Type(), Equals, plumbing.HashReference) c.Assert(branch.Hash().String(), Equals, "e8d3ffab552895c19b9fcf7aa264d277cde33881") } @@ -105,7 +105,7 @@ func (s *RepositorySuite) TestCloneNonEmpty(c *C) { r := NewMemoryRepository() head, err := r.Head() - c.Assert(err, Equals, core.ErrReferenceNotFound) + c.Assert(err, Equals, plumbing.ErrReferenceNotFound) c.Assert(head, IsNil) o := &CloneOptions{URL: RepositoryFixture} @@ -120,12 +120,12 @@ func (s *RepositorySuite) TestCloneSingleBranchAndNonHEAD(c *C) { r := NewMemoryRepository() head, err := r.Head() - c.Assert(err, Equals, core.ErrReferenceNotFound) + c.Assert(err, Equals, plumbing.ErrReferenceNotFound) c.Assert(head, IsNil) err = r.Clone(&CloneOptions{ URL: RepositoryFixture, - ReferenceName: core.ReferenceName("refs/heads/branch"), + ReferenceName: plumbing.ReferenceName("refs/heads/branch"), SingleBranch: true, }) @@ -135,10 +135,10 @@ func (s *RepositorySuite) TestCloneSingleBranchAndNonHEAD(c *C) { c.Assert(err, IsNil) c.Assert(remotes, HasLen, 1) - head, err = r.Ref(core.HEAD, false) + head, err = r.Ref(plumbing.HEAD, false) c.Assert(err, IsNil) c.Assert(head, NotNil) - c.Assert(head.Type(), Equals, core.SymbolicReference) + c.Assert(head.Type(), Equals, plumbing.SymbolicReference) c.Assert(head.Target().String(), Equals, "refs/heads/branch") branch, err := r.Ref(head.Target(), false) @@ -149,7 +149,7 @@ func (s *RepositorySuite) TestCloneSingleBranchAndNonHEAD(c *C) { branch, err = r.Ref("refs/remotes/origin/branch", false) c.Assert(err, IsNil) c.Assert(branch, NotNil) - c.Assert(branch.Type(), Equals, core.HashReference) + c.Assert(branch.Type(), Equals, plumbing.HashReference) c.Assert(branch.Hash().String(), Equals, "e8d3ffab552895c19b9fcf7aa264d277cde33881") } @@ -157,7 +157,7 @@ func (s *RepositorySuite) TestCloneSingleBranch(c *C) { r := NewMemoryRepository() head, err := r.Head() - c.Assert(err, Equals, core.ErrReferenceNotFound) + c.Assert(err, Equals, plumbing.ErrReferenceNotFound) c.Assert(head, IsNil) err = r.Clone(&CloneOptions{ @@ -171,10 +171,10 @@ func (s *RepositorySuite) TestCloneSingleBranch(c *C) { c.Assert(err, IsNil) c.Assert(remotes, HasLen, 1) - head, err = r.Ref(core.HEAD, false) + head, err = r.Ref(plumbing.HEAD, false) c.Assert(err, IsNil) c.Assert(head, NotNil) - c.Assert(head.Type(), Equals, core.SymbolicReference) + c.Assert(head.Type(), Equals, plumbing.SymbolicReference) c.Assert(head.Target().String(), Equals, "refs/heads/master") branch, err := r.Ref(head.Target(), false) @@ -185,7 +185,7 @@ func (s *RepositorySuite) TestCloneSingleBranch(c *C) { branch, err = r.Ref("refs/remotes/origin/master", false) c.Assert(err, IsNil) c.Assert(branch, NotNil) - c.Assert(branch.Type(), Equals, core.HashReference) + c.Assert(branch.Type(), Equals, plumbing.HashReference) c.Assert(branch.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5") } @@ -193,13 +193,13 @@ func (s *RepositorySuite) TestCloneDetachedHEAD(c *C) { r := NewMemoryRepository() err := r.Clone(&CloneOptions{ URL: RepositoryFixture, - ReferenceName: core.ReferenceName("refs/tags/v1.0.0"), + ReferenceName: plumbing.ReferenceName("refs/tags/v1.0.0"), }) - head, err := r.Ref(core.HEAD, false) + head, err := r.Ref(plumbing.HEAD, false) c.Assert(err, IsNil) c.Assert(head, NotNil) - c.Assert(head.Type(), Equals, core.HashReference) + c.Assert(head.Type(), Equals, plumbing.HashReference) c.Assert(head.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5") } @@ -259,14 +259,14 @@ func (s *RepositorySuite) TestCommit(c *C) { c.Assert(err, IsNil) - hash := core.NewHash("b8e471f58bcbca63b07bda20e428190409c2db47") + hash := plumbing.NewHash("b8e471f58bcbca63b07bda20e428190409c2db47") commit, err := r.Commit(hash) c.Assert(err, IsNil) c.Assert(commit.Hash.IsZero(), Equals, false) c.Assert(commit.Hash, Equals, commit.ID()) c.Assert(commit.Hash, Equals, hash) - c.Assert(commit.Type(), Equals, core.CommitObject) + c.Assert(commit.Type(), Equals, plumbing.CommitObject) tree, err := commit.Tree() c.Assert(err, IsNil) @@ -292,7 +292,7 @@ func (s *RepositorySuite) TestCommits(c *C) { count++ c.Assert(commit.Hash.IsZero(), Equals, false) c.Assert(commit.Hash, Equals, commit.ID()) - c.Assert(commit.Type(), Equals, core.CommitObject) + c.Assert(commit.Type(), Equals, plumbing.CommitObject) } c.Assert(count, Equals, 9) @@ -303,13 +303,13 @@ func (s *RepositorySuite) TestTag(c *C) { err := r.Clone(&CloneOptions{URL: "https://github.com/spinnaker/spinnaker.git"}) c.Assert(err, IsNil) - hash := core.NewHash("0a3fb06ff80156fb153bcdcc58b5e16c2d27625c") + hash := plumbing.NewHash("0a3fb06ff80156fb153bcdcc58b5e16c2d27625c") tag, err := r.Tag(hash) c.Assert(err, IsNil) c.Assert(tag.Hash.IsZero(), Equals, false) c.Assert(tag.Hash, Equals, hash) - c.Assert(tag.Type(), Equals, core.TagObject) + c.Assert(tag.Type(), Equals, plumbing.TagObject) } func (s *RepositorySuite) TestTags(c *C) { @@ -324,13 +324,13 @@ func (s *RepositorySuite) TestTags(c *C) { tags.ForEach(func(tag *Tag) error { count++ c.Assert(tag.Hash.IsZero(), Equals, false) - c.Assert(tag.Type(), Equals, core.TagObject) + c.Assert(tag.Type(), Equals, plumbing.TagObject) return nil }) refs, _ := r.Refs() - refs.ForEach(func(ref *core.Reference) error { + refs.ForEach(func(ref *plumbing.Reference) error { return nil }) @@ -352,13 +352,13 @@ func (s *RepositorySuite) TestRef(c *C) { err := r.Clone(&CloneOptions{URL: RepositoryFixture}) c.Assert(err, IsNil) - ref, err := r.Ref(core.HEAD, false) + ref, err := r.Ref(plumbing.HEAD, false) c.Assert(err, IsNil) - c.Assert(ref.Name(), Equals, core.HEAD) + c.Assert(ref.Name(), Equals, plumbing.HEAD) - ref, err = r.Ref(core.HEAD, true) + ref, err = r.Ref(plumbing.HEAD, true) c.Assert(err, IsNil) - c.Assert(ref.Name(), Equals, core.ReferenceName("refs/heads/master")) + c.Assert(ref.Name(), Equals, plumbing.ReferenceName("refs/heads/master")) } func (s *RepositorySuite) TestRefs(c *C) { @@ -378,13 +378,13 @@ func (s *RepositorySuite) TestObject(c *C) { err := r.Clone(&CloneOptions{URL: "https://github.com/spinnaker/spinnaker.git"}) c.Assert(err, IsNil) - hash := core.NewHash("0a3fb06ff80156fb153bcdcc58b5e16c2d27625c") + hash := plumbing.NewHash("0a3fb06ff80156fb153bcdcc58b5e16c2d27625c") tag, err := r.Tag(hash) c.Assert(err, IsNil) c.Assert(tag.Hash.IsZero(), Equals, false) c.Assert(tag.Hash, Equals, hash) - c.Assert(tag.Type(), Equals, core.TagObject) + c.Assert(tag.Type(), Equals, plumbing.TagObject) } func (s *RepositorySuite) TestObjectNotFound(c *C) { @@ -392,8 +392,8 @@ func (s *RepositorySuite) TestObjectNotFound(c *C) { err := r.Clone(&CloneOptions{URL: "https://github.com/git-fixtures/basic.git"}) c.Assert(err, IsNil) - hash := core.NewHash("0a3fb06ff80156fb153bcdcc58b5e16c2d27625c") - tag, err := r.Object(core.TagObject, hash) - c.Assert(err, DeepEquals, core.ErrObjectNotFound) + hash := plumbing.NewHash("0a3fb06ff80156fb153bcdcc58b5e16c2d27625c") + tag, err := r.Object(plumbing.TagObject, hash) + c.Assert(err, DeepEquals, plumbing.ErrObjectNotFound) c.Assert(tag, IsNil) } diff --git a/storage/filesystem/config.go b/storage/filesystem/config.go index 4b47937..510f51c 100644 --- a/storage/filesystem/config.go +++ b/storage/filesystem/config.go @@ -4,7 +4,7 @@ import ( "os" "gopkg.in/src-d/go-git.v4/config" - gitconfig "gopkg.in/src-d/go-git.v4/formats/config" + gitconfig "gopkg.in/src-d/go-git.v4/plumbing/format/config" "gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit" ) diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go index 6606153..3a6227e 100644 --- a/storage/filesystem/internal/dotgit/dotgit.go +++ b/storage/filesystem/internal/dotgit/dotgit.go @@ -9,7 +9,7 @@ import ( "os" "strings" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/utils/fs" ) @@ -76,7 +76,7 @@ func (d *DotGit) NewObjectPack() (*PackWriter, error) { } // ObjectPacks returns the list of availables packfiles -func (d *DotGit) ObjectPacks() ([]core.Hash, error) { +func (d *DotGit) ObjectPacks() ([]plumbing.Hash, error) { packDir := d.fs.Join(objectsPath, packPath) files, err := d.fs.ReadDir(packDir) if err != nil { @@ -87,14 +87,14 @@ func (d *DotGit) ObjectPacks() ([]core.Hash, error) { return nil, err } - var packs []core.Hash + var packs []plumbing.Hash for _, f := range files { if !strings.HasSuffix(f.Name(), packExt) { continue } n := f.Name() - h := core.NewHash(n[5 : len(n)-5]) //pack-(hash).pack + h := plumbing.NewHash(n[5 : len(n)-5]) //pack-(hash).pack packs = append(packs, h) } @@ -103,7 +103,7 @@ func (d *DotGit) ObjectPacks() ([]core.Hash, error) { } // ObjectPack returns a fs.File of the given packfile -func (d *DotGit) ObjectPack(hash core.Hash) (fs.File, error) { +func (d *DotGit) ObjectPack(hash plumbing.Hash) (fs.File, error) { file := d.fs.Join(objectsPath, packPath, fmt.Sprintf("pack-%s.pack", hash.String())) pack, err := d.fs.Open(file) @@ -119,7 +119,7 @@ func (d *DotGit) ObjectPack(hash core.Hash) (fs.File, error) { } // ObjectPackIdx returns a fs.File of the index file for a given packfile -func (d *DotGit) ObjectPackIdx(hash core.Hash) (fs.File, error) { +func (d *DotGit) ObjectPackIdx(hash plumbing.Hash) (fs.File, error) { file := d.fs.Join(objectsPath, packPath, fmt.Sprintf("pack-%s.idx", hash.String())) idx, err := d.fs.Open(file) if err != nil { @@ -140,7 +140,7 @@ func (d *DotGit) NewObject() (*ObjectWriter, error) { // Objects returns a slice with the hashes of objects found under the // .git/objects/ directory. -func (d *DotGit) Objects() ([]core.Hash, error) { +func (d *DotGit) Objects() ([]plumbing.Hash, error) { files, err := d.fs.ReadDir(objectsPath) if err != nil { if os.IsNotExist(err) { @@ -150,7 +150,7 @@ func (d *DotGit) Objects() ([]core.Hash, error) { return nil, err } - var objects []core.Hash + var objects []plumbing.Hash for _, f := range files { if f.IsDir() && len(f.Name()) == 2 && isHex(f.Name()) { base := f.Name() @@ -160,7 +160,7 @@ func (d *DotGit) Objects() ([]core.Hash, error) { } for _, o := range d { - objects = append(objects, core.NewHash(base+o.Name())) + objects = append(objects, plumbing.NewHash(base+o.Name())) } } } @@ -169,19 +169,19 @@ func (d *DotGit) Objects() ([]core.Hash, error) { } // Object return a fs.File poiting the object file, if exists -func (d *DotGit) Object(h core.Hash) (fs.File, error) { +func (d *DotGit) Object(h plumbing.Hash) (fs.File, error) { hash := h.String() file := d.fs.Join(objectsPath, hash[0:2], hash[2:40]) return d.fs.Open(file) } -func (d *DotGit) SetRef(r *core.Reference) error { +func (d *DotGit) SetRef(r *plumbing.Reference) error { var content string switch r.Type() { - case core.SymbolicReference: + case plumbing.SymbolicReference: content = fmt.Sprintf("ref: %s\n", r.Target()) - case core.HashReference: + case plumbing.HashReference: content = fmt.Sprintln(r.Hash().String()) } @@ -198,8 +198,8 @@ func (d *DotGit) SetRef(r *core.Reference) error { // Refs scans the git directory collecting references, which it returns. // Symbolic references are resolved and included in the output. -func (d *DotGit) Refs() ([]*core.Reference, error) { - var refs []*core.Reference +func (d *DotGit) Refs() ([]*plumbing.Reference, error) { + var refs []*plumbing.Reference if err := d.addRefsFromPackedRefs(&refs); err != nil { return nil, err } @@ -216,7 +216,7 @@ func (d *DotGit) Refs() ([]*core.Reference, error) { } // Ref returns the reference for a given reference name. -func (d *DotGit) Ref(name core.ReferenceName) (*core.Reference, error) { +func (d *DotGit) Ref(name plumbing.ReferenceName) (*plumbing.Reference, error) { ref, err := d.readReferenceFile(".", name.String()) if err == nil { return ref, nil @@ -233,10 +233,10 @@ func (d *DotGit) Ref(name core.ReferenceName) (*core.Reference, error) { } } - return nil, core.ErrReferenceNotFound + return nil, plumbing.ErrReferenceNotFound } -func (d *DotGit) addRefsFromPackedRefs(refs *[]*core.Reference) (err error) { +func (d *DotGit) addRefsFromPackedRefs(refs *[]*plumbing.Reference) (err error) { f, err := d.fs.Open(packedRefsPath) if err != nil { if os.IsNotExist(err) { @@ -267,7 +267,7 @@ func (d *DotGit) addRefsFromPackedRefs(refs *[]*core.Reference) (err error) { } // process lines from a packed-refs file -func (d *DotGit) processLine(line string) (*core.Reference, error) { +func (d *DotGit) processLine(line string) (*plumbing.Reference, error) { switch line[0] { case '#': // comment - ignore return nil, nil @@ -279,15 +279,15 @@ func (d *DotGit) processLine(line string) (*core.Reference, error) { return nil, ErrPackedRefsBadFormat } - return core.NewReferenceFromStrings(ws[1], ws[0]), nil + return plumbing.NewReferenceFromStrings(ws[1], ws[0]), nil } } -func (d *DotGit) addRefsFromRefDir(refs *[]*core.Reference) error { +func (d *DotGit) addRefsFromRefDir(refs *[]*plumbing.Reference) error { return d.walkReferencesTree(refs, refsPath) } -func (d *DotGit) walkReferencesTree(refs *[]*core.Reference, relPath string) error { +func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string) error { files, err := d.fs.ReadDir(relPath) if err != nil { if os.IsNotExist(err) { @@ -320,7 +320,7 @@ func (d *DotGit) walkReferencesTree(refs *[]*core.Reference, relPath string) err return nil } -func (d *DotGit) addRefFromHEAD(refs *[]*core.Reference) error { +func (d *DotGit) addRefFromHEAD(refs *[]*plumbing.Reference) error { ref, err := d.readReferenceFile(".", "HEAD") if err != nil { if os.IsNotExist(err) { @@ -334,7 +334,7 @@ func (d *DotGit) addRefFromHEAD(refs *[]*core.Reference) error { return nil } -func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *core.Reference, err error) { +func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *plumbing.Reference, err error) { path := d.fs.Join(refsPath, refFile) f, err := d.fs.Open(path) @@ -354,7 +354,7 @@ func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *core.Referenc } line := strings.TrimSpace(string(b)) - return core.NewReferenceFromStrings(refFile, line), nil + return plumbing.NewReferenceFromStrings(refFile, line), nil } func isHex(s string) bool { diff --git a/storage/filesystem/internal/dotgit/dotgit_test.go b/storage/filesystem/internal/dotgit/dotgit_test.go index a5d25e3..bcd8d96 100644 --- a/storage/filesystem/internal/dotgit/dotgit_test.go +++ b/storage/filesystem/internal/dotgit/dotgit_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" + "gopkg.in/src-d/go-git.v4/plumbing" osfs "gopkg.in/src-d/go-git.v4/utils/fs/os" . "gopkg.in/check.v1" @@ -30,21 +30,21 @@ func (s *SuiteDotGit) TestSetRefs(c *C) { fs := osfs.New(tmp) dir := New(fs) - err = dir.SetRef(core.NewReferenceFromStrings( + err = dir.SetRef(plumbing.NewReferenceFromStrings( "refs/heads/foo", "e8d3ffab552895c19b9fcf7aa264d277cde33881", )) c.Assert(err, IsNil) - err = dir.SetRef(core.NewReferenceFromStrings( + err = dir.SetRef(plumbing.NewReferenceFromStrings( "refs/heads/symbolic", "ref: refs/heads/foo", )) c.Assert(err, IsNil) - err = dir.SetRef(core.NewReferenceFromStrings( + err = dir.SetRef(plumbing.NewReferenceFromStrings( "bar", "e8d3ffab552895c19b9fcf7aa264d277cde33881", )) @@ -103,7 +103,7 @@ func (s *SuiteDotGit) TestRefsFromReferenceFile(c *C) { ref := findReference(refs, "refs/remotes/origin/HEAD") c.Assert(ref, NotNil) - c.Assert(ref.Type(), Equals, core.SymbolicReference) + c.Assert(ref.Type(), Equals, plumbing.SymbolicReference) c.Assert(string(ref.Target()), Equals, "refs/remotes/origin/master") } @@ -117,7 +117,7 @@ func (s *SuiteDotGit) TestRefsFromHEADFile(c *C) { ref := findReference(refs, "HEAD") c.Assert(ref, NotNil) - c.Assert(ref.Type(), Equals, core.SymbolicReference) + c.Assert(ref.Type(), Equals, plumbing.SymbolicReference) c.Assert(string(ref.Target()), Equals, "refs/heads/master") } @@ -130,8 +130,8 @@ func (s *SuiteDotGit) TestConfig(c *C) { c.Assert(filepath.Base(file.Filename()), Equals, "config") } -func findReference(refs []*core.Reference, name string) *core.Reference { - n := core.ReferenceName(name) +func findReference(refs []*plumbing.Reference, name string) *plumbing.Reference { + n := plumbing.ReferenceName(name) for _, ref := range refs { if ref.Name() == n { return ref @@ -176,11 +176,11 @@ func (s *SuiteDotGit) TestObjectPackNotFound(c *C) { fs := fixtures.Basic().ByTag(".git").One().DotGit() dir := New(fs) - pack, err := dir.ObjectPack(core.ZeroHash) + pack, err := dir.ObjectPack(plumbing.ZeroHash) c.Assert(err, Equals, ErrPackfileNotFound) c.Assert(pack, IsNil) - idx, err := dir.ObjectPackIdx(core.ZeroHash) + idx, err := dir.ObjectPackIdx(plumbing.ZeroHash) c.Assert(idx, IsNil) } @@ -194,7 +194,7 @@ func (s *SuiteDotGit) TestNewObject(c *C) { w, err := dir.NewObject() c.Assert(err, IsNil) - err = w.WriteHeader(core.BlobObject, 14) + err = w.WriteHeader(plumbing.BlobObject, 14) n, err := w.Write([]byte("this is a test")) c.Assert(err, IsNil) c.Assert(n, Equals, 14) @@ -225,7 +225,7 @@ func (s *SuiteDotGit) TestObject(c *C) { fs := fixtures.ByTag(".git").ByTag("unpacked").One().DotGit() dir := New(fs) - hash := core.NewHash("03db8e1fbe133a480f2867aac478fd866686d69e") + hash := plumbing.NewHash("03db8e1fbe133a480f2867aac478fd866686d69e") file, err := dir.Object(hash) c.Assert(err, IsNil) c.Assert(strings.HasSuffix( @@ -238,7 +238,7 @@ func (s *SuiteDotGit) TestObjectNotFound(c *C) { fs := fixtures.ByTag(".git").ByTag("unpacked").One().DotGit() dir := New(fs) - hash := core.NewHash("not-found-object") + hash := plumbing.NewHash("not-found-object") file, err := dir.Object(hash) c.Assert(err, NotNil) c.Assert(file, IsNil) diff --git a/storage/filesystem/internal/dotgit/writers.go b/storage/filesystem/internal/dotgit/writers.go index 4641572..d3d3b43 100644 --- a/storage/filesystem/internal/dotgit/writers.go +++ b/storage/filesystem/internal/dotgit/writers.go @@ -5,20 +5,20 @@ import ( "io" "sync/atomic" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/idxfile" - "gopkg.in/src-d/go-git.v4/formats/objfile" - "gopkg.in/src-d/go-git.v4/formats/packfile" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/idxfile" + "gopkg.in/src-d/go-git.v4/plumbing/format/objfile" + "gopkg.in/src-d/go-git.v4/plumbing/format/packfile" "gopkg.in/src-d/go-git.v4/utils/fs" ) type PackWriter struct { - Notify func(h core.Hash, i idxfile.Idxfile) + Notify func(h plumbing.Hash, i idxfile.Idxfile) fs fs.Filesystem fr, fw fs.File synced *syncedReader - checksum core.Hash + checksum plumbing.Hash index idxfile.Idxfile result chan error } diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go index f780183..5868748 100644 --- a/storage/filesystem/object.go +++ b/storage/filesystem/object.go @@ -4,10 +4,11 @@ import ( "io" "os" - "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/idxfile" - "gopkg.in/src-d/go-git.v4/formats/objfile" - "gopkg.in/src-d/go-git.v4/formats/packfile" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/format/idxfile" + "gopkg.in/src-d/go-git.v4/plumbing/format/objfile" + "gopkg.in/src-d/go-git.v4/plumbing/format/packfile" + "gopkg.in/src-d/go-git.v4/plumbing/storer" "gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit" "gopkg.in/src-d/go-git.v4/storage/memory" "gopkg.in/src-d/go-git.v4/utils/fs" @@ -15,13 +16,13 @@ import ( type ObjectStorage struct { dir *dotgit.DotGit - index map[core.Hash]index + index map[plumbing.Hash]index } func newObjectStorage(dir *dotgit.DotGit) (ObjectStorage, error) { s := ObjectStorage{ dir: dir, - index: make(map[core.Hash]index, 0), + index: make(map[plumbing.Hash]index, 0), } return s, s.loadIdxFiles() @@ -42,7 +43,7 @@ func (s *ObjectStorage) loadIdxFiles() error { return nil } -func (s *ObjectStorage) loadIdxFile(h core.Hash) error { +func (s *ObjectStorage) loadIdxFile(h plumbing.Hash) error { idx, err := s.dir.ObjectPackIdx(h) if err != nil { return err @@ -52,8 +53,8 @@ func (s *ObjectStorage) loadIdxFile(h core.Hash) error { return s.index[h].Decode(idx) } -func (s *ObjectStorage) NewObject() core.Object { - return &core.MemoryObject{} +func (s *ObjectStorage) NewObject() plumbing.Object { + return &plumbing.MemoryObject{} } func (s *ObjectStorage) PackfileWriter() (io.WriteCloser, error) { @@ -62,7 +63,7 @@ func (s *ObjectStorage) PackfileWriter() (io.WriteCloser, error) { return nil, err } - w.Notify = func(h core.Hash, idx idxfile.Idxfile) { + w.Notify = func(h plumbing.Hash, idx idxfile.Idxfile) { s.index[h] = make(index) for _, e := range idx.Entries { s.index[h][e.Hash] = int64(e.Offset) @@ -73,31 +74,31 @@ func (s *ObjectStorage) PackfileWriter() (io.WriteCloser, error) { } // Set adds a new object to the storage. -func (s *ObjectStorage) SetObject(o core.Object) (core.Hash, error) { - if o.Type() == core.OFSDeltaObject || o.Type() == core.REFDeltaObject { - return core.ZeroHash, core.ErrInvalidType +func (s *ObjectStorage) SetObject(o plumbing.Object) (plumbing.Hash, error) { + if o.Type() == plumbing.OFSDeltaObject || o.Type() == plumbing.REFDeltaObject { + return plumbing.ZeroHash, plumbing.ErrInvalidType } ow, err := s.dir.NewObject() if err != nil { - return core.ZeroHash, err + return plumbing.ZeroHash, err } defer ow.Close() or, err := o.Reader() if err != nil { - return core.ZeroHash, err + return plumbing.ZeroHash, err } defer or.Close() if err := ow.WriteHeader(o.Type(), o.Size()); err != nil { - return core.ZeroHash, err + return plumbing.ZeroHash, err } if _, err := io.Copy(ow, or); err != nil { - return core.ZeroHash, err + return plumbing.ZeroHash, err } return o.Hash(), nil @@ -105,9 +106,9 @@ func (s *ObjectStorage) SetObject(o core.Object) (core.Hash, error) { // Get returns the object with the given hash, by searching for it in // the packfile and the git object directories. -func (s *ObjectStorage) Object(t core.ObjectType, h core.Hash) (core.Object, error) { +func (s *ObjectStorage) Object(t plumbing.ObjectType, h plumbing.Hash) (plumbing.Object, error) { obj, err := s.getFromUnpacked(h) - if err == core.ErrObjectNotFound { + if err == plumbing.ErrObjectNotFound { obj, err = s.getFromPackfile(h) } @@ -115,18 +116,18 @@ func (s *ObjectStorage) Object(t core.ObjectType, h core.Hash) (core.Object, err return nil, err } - if core.AnyObject != t && obj.Type() != t { - return nil, core.ErrObjectNotFound + if plumbing.AnyObject != t && obj.Type() != t { + return nil, plumbing.ErrObjectNotFound } return obj, nil } -func (s *ObjectStorage) getFromUnpacked(h core.Hash) (obj core.Object, err error) { +func (s *ObjectStorage) getFromUnpacked(h plumbing.Hash) (obj plumbing.Object, err error) { f, err := s.dir.Object(h) if err != nil { if os.IsNotExist(err) { - return nil, core.ErrObjectNotFound + return nil, plumbing.ErrObjectNotFound } return nil, err @@ -160,10 +161,10 @@ func (s *ObjectStorage) getFromUnpacked(h core.Hash) (obj core.Object, err error // Get returns the object with the given hash, by searching for it in // the packfile. -func (s *ObjectStorage) getFromPackfile(h core.Hash) (core.Object, error) { +func (s *ObjectStorage) getFromPackfile(h plumbing.Hash) (plumbing.Object, error) { pack, offset := s.findObjectInPackfile(h) if offset == -1 { - return nil, core.ErrObjectNotFound + return nil, plumbing.ErrObjectNotFound } f, err := s.dir.ObjectPack(pack) @@ -183,26 +184,26 @@ func (s *ObjectStorage) getFromPackfile(h core.Hash) (core.Object, error) { return d.ReadObjectAt(offset) } -func (s *ObjectStorage) findObjectInPackfile(h core.Hash) (core.Hash, int64) { +func (s *ObjectStorage) findObjectInPackfile(h plumbing.Hash) (plumbing.Hash, int64) { for packfile, index := range s.index { if offset, ok := index[h]; ok { return packfile, offset } } - return core.ZeroHash, -1 + return plumbing.ZeroHash, -1 } // Iter returns an iterator for all the objects in the packfile with the // given type. -func (s *ObjectStorage) IterObjects(t core.ObjectType) (core.ObjectIter, error) { +func (s *ObjectStorage) IterObjects(t plumbing.ObjectType) (storer.ObjectIter, error) { objects, err := s.dir.Objects() if err != nil { return nil, err } - seen := make(map[core.Hash]bool, 0) - var iters []core.ObjectIter + seen := make(map[plumbing.Hash]bool, 0) + var iters []storer.ObjectIter if len(objects) != 0 { iters = append(iters, &objectsIter{s: s, t: t, h: objects}) seen = hashListAsMap(objects) @@ -214,17 +215,17 @@ func (s *ObjectStorage) IterObjects(t core.ObjectType) (core.ObjectIter, error) } iters = append(iters, packi...) - return core.NewMultiObjectIter(iters), nil + return storer.NewMultiObjectIter(iters), nil } func (s *ObjectStorage) buildPackfileIters( - t core.ObjectType, seen map[core.Hash]bool) ([]core.ObjectIter, error) { + t plumbing.ObjectType, seen map[plumbing.Hash]bool) ([]storer.ObjectIter, error) { packs, err := s.dir.ObjectPacks() if err != nil { return nil, err } - var iters []core.ObjectIter + var iters []storer.ObjectIter for _, h := range packs { pack, err := s.dir.ObjectPack(h) if err != nil { @@ -242,7 +243,7 @@ func (s *ObjectStorage) buildPackfileIters( return iters, nil } -type index map[core.Hash]int64 +type index map[plumbing.Hash]int64 func (i index) Decode(r io.Reader) error { idx := &idxfile.Idxfile{} @@ -262,14 +263,14 @@ func (i index) Decode(r io.Reader) error { type packfileIter struct { f fs.File d *packfile.Decoder - t core.ObjectType + t plumbing.ObjectType - seen map[core.Hash]bool + seen map[plumbing.Hash]bool position uint32 total uint32 } -func newPackfileIter(f fs.File, t core.ObjectType, seen map[core.Hash]bool) (core.ObjectIter, error) { +func newPackfileIter(f fs.File, t plumbing.ObjectType, seen map[plumbing.Hash]bool) (storer.ObjectIter, error) { s := packfile.NewScanner(f) _, total, err := s.Header() if err != nil { @@ -291,7 +292,7 @@ func newPackfileIter(f fs.File, t core.ObjectType, seen map[core.Hash]bool) (cor }, nil } -func (iter *packfileIter) Next() (core.Object, error) { +func (iter *packfileIter) Next() (plumbing.Object, error) { if iter.position >= iter.total { return nil, io.EOF } @@ -306,7 +307,7 @@ func (iter *packfileIter) Next() (core.Object, error) { return iter.Next() } - if iter.t != core.AnyObject && iter.t != obj.Type() { + if iter.t != plumbing.AnyObject && iter.t != obj.Type() { return iter.Next() } @@ -314,7 +315,7 @@ func (iter *packfileIter) Next() (core.Object, error) { } // ForEach is never called since is used inside of a MultiObjectIterator -func (iter *packfileIter) ForEach(cb func(core.Object) error) error { +func (iter *packfileIter) ForEach(cb func(plumbing.Object) error) error { return nil } @@ -325,11 +326,11 @@ func (iter *packfileIter) Close() { type objectsIter struct { s *ObjectStorage - t core.ObjectType - h []core.Hash + t plumbing.ObjectType + h []plumbing.Hash } -func (iter *objectsIter) Next() (core.Object, error) { +func (iter *objectsIter) Next() (plumbing.Object, error) { if len(iter.h) == 0 { return nil, io.EOF } @@ -341,7 +342,7 @@ func (iter *objectsIter) Next() (core.Object, error) { return nil, err } - if iter.t != core.AnyObject && iter.t != obj.Type() { + if iter.t != plumbing.AnyObject && iter.t != obj.Type() { return iter.Next() } @@ -349,16 +350,16 @@ func (iter *objectsIter) Next() (core.Object, error) { } // ForEach is never called since is used inside of a MultiObjectIterator -func (iter *objectsIter) ForEach(cb func(core.Object) error) error { +func (iter *objectsIter) ForEach(cb func(plumbing.Object) error) error { return nil } func (iter *objectsIter) Close() { - iter.h = []core.Hash{} + iter.h = []plumbing.Hash{} } -func hashListAsMap(l []core.Hash) map[core.Hash]bool { - m := make(map[core.Hash]bool, len(l)) +func hashListAsMap(l []plumbing.Hash) map[plumbing.Hash]bool { + m := make(map[plumbing.Hash]bool, len(l)) for _, h := range l { m[h] = true } diff --git a/storage/filesystem/object_test.go b/storage/filesystem/object_test.go index 38e4b6d..f839420 100644 --- a/storage/filesystem/object_test.go +++ b/storage/filesystem/object_test.go @@ -1,8 +1,8 @@ package filesystem import ( - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" + "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit" . "gopkg.in/check.v1" @@ -19,8 +19,8 @@ func (s *FsSuite) TestGetFromObjectFile(c *C) { o, err := newObjectStorage(dotgit.New(fs)) c.Assert(err, IsNil) - expected := core.NewHash("f3dfe29d268303fc6e1bbce268605fc99573406e") - obj, err := o.Object(core.AnyObject, expected) + expected := plumbing.NewHash("f3dfe29d268303fc6e1bbce268605fc99573406e") + obj, err := o.Object(plumbing.AnyObject, expected) c.Assert(err, IsNil) c.Assert(obj.Hash(), Equals, expected) } @@ -31,8 +31,8 @@ func (s *FsSuite) TestGetFromPackfile(c *C) { o, err := newObjectStorage(dotgit.New(fs)) c.Assert(err, IsNil) - expected := core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") - obj, err := o.Object(core.AnyObject, expected) + expected := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") + obj, err := o.Object(plumbing.AnyObject, expected) c.Assert(err, IsNil) c.Assert(obj.Hash(), Equals, expected) }) @@ -43,12 +43,12 @@ func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) { o, err := newObjectStorage(dotgit.New(fs)) c.Assert(err, IsNil) - expected := core.NewHash("8d45a34641d73851e01d3754320b33bb5be3c4d3") + expected := plumbing.NewHash("8d45a34641d73851e01d3754320b33bb5be3c4d3") obj, err := o.getFromPackfile(expected) c.Assert(err, IsNil) c.Assert(obj.Hash(), Equals, expected) - expected = core.NewHash("e9cfa4c9ca160546efd7e8582ec77952a27b17db") + expected = plumbing.NewHash("e9cfa4c9ca160546efd7e8582ec77952a27b17db") obj, err = o.getFromPackfile(expected) c.Assert(err, IsNil) c.Assert(obj.Hash(), Equals, expected) @@ -60,11 +60,11 @@ func (s *FsSuite) TestIter(c *C) { o, err := newObjectStorage(dotgit.New(fs)) c.Assert(err, IsNil) - iter, err := o.IterObjects(core.AnyObject) + iter, err := o.IterObjects(plumbing.AnyObject) c.Assert(err, IsNil) var count int32 - err = iter.ForEach(func(o core.Object) error { + err = iter.ForEach(func(o plumbing.Object) error { count++ return nil }) @@ -80,11 +80,11 @@ func (s *FsSuite) TestIterWithType(c *C) { o, err := newObjectStorage(dotgit.New(fs)) c.Assert(err, IsNil) - iter, err := o.IterObjects(core.CommitObject) + iter, err := o.IterObjects(plumbing.CommitObject) c.Assert(err, IsNil) - err = iter.ForEach(func(o core.Object) error { - c.Assert(o.Type(), Equals, core.CommitObject) + err = iter.ForEach(func(o plumbing.Object) error { + c.Assert(o.Type(), Equals, plumbing.CommitObject) return nil }) diff --git a/storage/filesystem/reference.go b/storage/filesystem/reference.go index 0015859..93da68c 100644 --- a/storage/filesystem/reference.go +++ b/storage/filesystem/reference.go @@ -1,7 +1,8 @@ package filesystem import ( - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" "gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit" ) @@ -9,19 +10,19 @@ type ReferenceStorage struct { dir *dotgit.DotGit } -func (r *ReferenceStorage) SetReference(ref *core.Reference) error { +func (r *ReferenceStorage) SetReference(ref *plumbing.Reference) error { return r.dir.SetRef(ref) } -func (r *ReferenceStorage) Reference(n core.ReferenceName) (*core.Reference, error) { +func (r *ReferenceStorage) Reference(n plumbing.ReferenceName) (*plumbing.Reference, error) { return r.dir.Ref(n) } -func (r *ReferenceStorage) IterReferences() (core.ReferenceIter, error) { +func (r *ReferenceStorage) IterReferences() (storer.ReferenceIter, error) { refs, err := r.dir.Refs() if err != nil { return nil, err } - return core.NewReferenceSliceIter(refs), nil + return storer.NewReferenceSliceIter(refs), nil } diff --git a/storage/memory/storage.go b/storage/memory/storage.go index 8141cfc..a7a2150 100644 --- a/storage/memory/storage.go +++ b/storage/memory/storage.go @@ -5,7 +5,8 @@ import ( "fmt" "gopkg.in/src-d/go-git.v4/config" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" ) var ErrUnsupportedObjectType = fmt.Errorf("unsupported object type") @@ -26,11 +27,11 @@ func NewStorage() *Storage { ReferenceStorage: make(ReferenceStorage, 0), ConfigStorage: ConfigStorage{}, ObjectStorage: ObjectStorage{ - Objects: make(map[core.Hash]core.Object, 0), - Commits: make(map[core.Hash]core.Object, 0), - Trees: make(map[core.Hash]core.Object, 0), - Blobs: make(map[core.Hash]core.Object, 0), - Tags: make(map[core.Hash]core.Object, 0), + Objects: make(map[plumbing.Hash]plumbing.Object, 0), + Commits: make(map[plumbing.Hash]plumbing.Object, 0), + Trees: make(map[plumbing.Hash]plumbing.Object, 0), + Blobs: make(map[plumbing.Hash]plumbing.Object, 0), + Tags: make(map[plumbing.Hash]plumbing.Object, 0), }, } } @@ -57,29 +58,29 @@ func (c *ConfigStorage) Config() (*config.Config, error) { } type ObjectStorage struct { - Objects map[core.Hash]core.Object - Commits map[core.Hash]core.Object - Trees map[core.Hash]core.Object - Blobs map[core.Hash]core.Object - Tags map[core.Hash]core.Object + Objects map[plumbing.Hash]plumbing.Object + Commits map[plumbing.Hash]plumbing.Object + Trees map[plumbing.Hash]plumbing.Object + Blobs map[plumbing.Hash]plumbing.Object + Tags map[plumbing.Hash]plumbing.Object } -func (o *ObjectStorage) NewObject() core.Object { - return &core.MemoryObject{} +func (o *ObjectStorage) NewObject() plumbing.Object { + return &plumbing.MemoryObject{} } -func (o *ObjectStorage) SetObject(obj core.Object) (core.Hash, error) { +func (o *ObjectStorage) SetObject(obj plumbing.Object) (plumbing.Hash, error) { h := obj.Hash() o.Objects[h] = obj switch obj.Type() { - case core.CommitObject: + case plumbing.CommitObject: o.Commits[h] = o.Objects[h] - case core.TreeObject: + case plumbing.TreeObject: o.Trees[h] = o.Objects[h] - case core.BlobObject: + case plumbing.BlobObject: o.Blobs[h] = o.Objects[h] - case core.TagObject: + case plumbing.TagObject: o.Tags[h] = o.Objects[h] default: return h, ErrUnsupportedObjectType @@ -88,64 +89,64 @@ func (o *ObjectStorage) SetObject(obj core.Object) (core.Hash, error) { return h, nil } -func (o *ObjectStorage) Object(t core.ObjectType, h core.Hash) (core.Object, error) { +func (o *ObjectStorage) Object(t plumbing.ObjectType, h plumbing.Hash) (plumbing.Object, error) { obj, ok := o.Objects[h] - if !ok || (core.AnyObject != t && obj.Type() != t) { - return nil, core.ErrObjectNotFound + if !ok || (plumbing.AnyObject != t && obj.Type() != t) { + return nil, plumbing.ErrObjectNotFound } return obj, nil } -func (o *ObjectStorage) IterObjects(t core.ObjectType) (core.ObjectIter, error) { - var series []core.Object +func (o *ObjectStorage) IterObjects(t plumbing.ObjectType) (storer.ObjectIter, error) { + var series []plumbing.Object switch t { - case core.AnyObject: + case plumbing.AnyObject: series = flattenObjectMap(o.Objects) - case core.CommitObject: + case plumbing.CommitObject: series = flattenObjectMap(o.Commits) - case core.TreeObject: + case plumbing.TreeObject: series = flattenObjectMap(o.Trees) - case core.BlobObject: + case plumbing.BlobObject: series = flattenObjectMap(o.Blobs) - case core.TagObject: + case plumbing.TagObject: series = flattenObjectMap(o.Tags) } - return core.NewObjectSliceIter(series), nil + return storer.NewObjectSliceIter(series), nil } -func flattenObjectMap(m map[core.Hash]core.Object) []core.Object { - objects := make([]core.Object, 0, len(m)) +func flattenObjectMap(m map[plumbing.Hash]plumbing.Object) []plumbing.Object { + objects := make([]plumbing.Object, 0, len(m)) for _, obj := range m { objects = append(objects, obj) } return objects } -func (o *ObjectStorage) Begin() core.Transaction { +func (o *ObjectStorage) Begin() storer.Transaction { return &TxObjectStorage{ Storage: o, - Objects: make(map[core.Hash]core.Object, 0), + Objects: make(map[plumbing.Hash]plumbing.Object, 0), } } type TxObjectStorage struct { Storage *ObjectStorage - Objects map[core.Hash]core.Object + Objects map[plumbing.Hash]plumbing.Object } -func (tx *TxObjectStorage) SetObject(obj core.Object) (core.Hash, error) { +func (tx *TxObjectStorage) SetObject(obj plumbing.Object) (plumbing.Hash, error) { h := obj.Hash() tx.Objects[h] = obj return h, nil } -func (tx *TxObjectStorage) Object(t core.ObjectType, h core.Hash) (core.Object, error) { +func (tx *TxObjectStorage) Object(t plumbing.ObjectType, h plumbing.Hash) (plumbing.Object, error) { obj, ok := tx.Objects[h] - if !ok || (core.AnyObject != t && obj.Type() != t) { - return nil, core.ErrObjectNotFound + if !ok || (plumbing.AnyObject != t && obj.Type() != t) { + return nil, plumbing.ErrObjectNotFound } return obj, nil @@ -163,13 +164,13 @@ func (tx *TxObjectStorage) Commit() error { } func (tx *TxObjectStorage) Rollback() error { - tx.Objects = make(map[core.Hash]core.Object, 0) + tx.Objects = make(map[plumbing.Hash]plumbing.Object, 0) return nil } -type ReferenceStorage map[core.ReferenceName]*core.Reference +type ReferenceStorage map[plumbing.ReferenceName]*plumbing.Reference -func (r ReferenceStorage) SetReference(ref *core.Reference) error { +func (r ReferenceStorage) SetReference(ref *plumbing.Reference) error { if ref != nil { r[ref.Name()] = ref } @@ -177,20 +178,20 @@ func (r ReferenceStorage) SetReference(ref *core.Reference) error { return nil } -func (r ReferenceStorage) Reference(n core.ReferenceName) (*core.Reference, error) { +func (r ReferenceStorage) Reference(n plumbing.ReferenceName) (*plumbing.Reference, error) { ref, ok := r[n] if !ok { - return nil, core.ErrReferenceNotFound + return nil, plumbing.ErrReferenceNotFound } return ref, nil } -func (r ReferenceStorage) IterReferences() (core.ReferenceIter, error) { - var refs []*core.Reference +func (r ReferenceStorage) IterReferences() (storer.ReferenceIter, error) { + var refs []*plumbing.Reference for _, ref := range r { refs = append(refs, ref) } - return core.NewReferenceSliceIter(refs), nil + return storer.NewReferenceSliceIter(refs), nil } diff --git a/storage/test/storage_suite.go b/storage/test/storage_suite.go index 451528f..d5e1464 100644 --- a/storage/test/storage_suite.go +++ b/storage/test/storage_suite.go @@ -8,53 +8,54 @@ import ( "io/ioutil" "gopkg.in/src-d/go-git.v4/config" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" . "gopkg.in/check.v1" ) -type storer interface { - core.ObjectStorer - core.ReferenceStorer +type Storer interface { + storer.ObjectStorer + storer.ReferenceStorer config.ConfigStorer } type TestObject struct { - Object core.Object + Object plumbing.Object Hash string - Type core.ObjectType + Type plumbing.ObjectType } type BaseStorageSuite struct { - Storer storer + Storer Storer - validTypes []core.ObjectType - testObjects map[core.ObjectType]TestObject + validTypes []plumbing.ObjectType + testObjects map[plumbing.ObjectType]TestObject } -func NewBaseStorageSuite(s storer) BaseStorageSuite { - commit := &core.MemoryObject{} - commit.SetType(core.CommitObject) - tree := &core.MemoryObject{} - tree.SetType(core.TreeObject) - blob := &core.MemoryObject{} - blob.SetType(core.BlobObject) - tag := &core.MemoryObject{} - tag.SetType(core.TagObject) +func NewBaseStorageSuite(s Storer) BaseStorageSuite { + commit := &plumbing.MemoryObject{} + commit.SetType(plumbing.CommitObject) + tree := &plumbing.MemoryObject{} + tree.SetType(plumbing.TreeObject) + blob := &plumbing.MemoryObject{} + blob.SetType(plumbing.BlobObject) + tag := &plumbing.MemoryObject{} + tag.SetType(plumbing.TagObject) return BaseStorageSuite{ Storer: s, - validTypes: []core.ObjectType{ - core.CommitObject, - core.BlobObject, - core.TagObject, - core.TreeObject, + validTypes: []plumbing.ObjectType{ + plumbing.CommitObject, + plumbing.BlobObject, + plumbing.TagObject, + plumbing.TreeObject, }, - testObjects: map[core.ObjectType]TestObject{ - core.CommitObject: {commit, "dcf5b16e76cce7425d0beaef62d79a7d10fce1f5", core.CommitObject}, - core.TreeObject: {tree, "4b825dc642cb6eb9a060e54bf8d69288fbee4904", core.TreeObject}, - core.BlobObject: {blob, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", core.BlobObject}, - core.TagObject: {tag, "d994c6bb648123a17e8f70a966857c546b2a6f94", core.TagObject}, + testObjects: map[plumbing.ObjectType]TestObject{ + plumbing.CommitObject: {commit, "dcf5b16e76cce7425d0beaef62d79a7d10fce1f5", plumbing.CommitObject}, + plumbing.TreeObject: {tree, "4b825dc642cb6eb9a060e54bf8d69288fbee4904", plumbing.TreeObject}, + plumbing.BlobObject: {blob, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", plumbing.BlobObject}, + plumbing.TagObject: {tag, "d994c6bb648123a17e8f70a966857c546b2a6f94", plumbing.TagObject}, }} } @@ -70,7 +71,7 @@ func (s *BaseStorageSuite) TestSetObjectAndGetObject(c *C) { c.Assert(err, IsNil) c.Assert(objectEquals(o, to.Object), IsNil) - o, err = s.Storer.Object(core.AnyObject, h) + o, err = s.Storer.Object(plumbing.AnyObject, h) c.Assert(err, IsNil) c.Assert(objectEquals(o, to.Object), IsNil) @@ -81,14 +82,14 @@ func (s *BaseStorageSuite) TestSetObjectAndGetObject(c *C) { o, err = s.Storer.Object(t, h) c.Assert(o, IsNil) - c.Assert(err, Equals, core.ErrObjectNotFound) + c.Assert(err, Equals, plumbing.ErrObjectNotFound) } } } func (s *BaseStorageSuite) TestSetObjectInvalid(c *C) { o := s.Storer.NewObject() - o.SetType(core.REFDeltaObject) + o.SetType(plumbing.REFDeltaObject) _, err := s.Storer.SetObject(o) c.Assert(err, NotNil) @@ -115,11 +116,11 @@ func (s *BaseStorageSuite) TestStorerIter(c *C) { c.Assert(err, Equals, io.EOF, comment) } - i, err := s.Storer.IterObjects(core.AnyObject) + i, err := s.Storer.IterObjects(plumbing.AnyObject) c.Assert(err, IsNil) - foundObjects := []core.Object{} - i.ForEach(func(o core.Object) error { + foundObjects := []plumbing.Object{} + i.ForEach(func(o plumbing.Object) error { foundObjects = append(foundObjects, o) return nil }) @@ -138,9 +139,9 @@ func (s *BaseStorageSuite) TestStorerIter(c *C) { } func (s *BaseStorageSuite) TestObjectStorerTxSetObjectAndCommit(c *C) { - storer, ok := s.Storer.(core.Transactioner) + storer, ok := s.Storer.(storer.Transactioner) if !ok { - c.Skip("not a core.ObjectStorerTx") + c.Skip("not a plumbing.ObjectStorerTx") } tx := storer.Begin() @@ -150,7 +151,7 @@ func (s *BaseStorageSuite) TestObjectStorerTxSetObjectAndCommit(c *C) { c.Assert(h.String(), Equals, o.Hash) } - iter, err := s.Storer.IterObjects(core.AnyObject) + iter, err := s.Storer.IterObjects(plumbing.AnyObject) c.Assert(err, IsNil) _, err = iter.Next() c.Assert(err, Equals, io.EOF) @@ -158,11 +159,11 @@ func (s *BaseStorageSuite) TestObjectStorerTxSetObjectAndCommit(c *C) { err = tx.Commit() c.Assert(err, IsNil) - iter, err = s.Storer.IterObjects(core.AnyObject) + iter, err = s.Storer.IterObjects(plumbing.AnyObject) c.Assert(err, IsNil) var count int - iter.ForEach(func(o core.Object) error { + iter.ForEach(func(o plumbing.Object) error { count++ return nil }) @@ -171,9 +172,9 @@ func (s *BaseStorageSuite) TestObjectStorerTxSetObjectAndCommit(c *C) { } func (s *BaseStorageSuite) TestObjectStorerTxSetObjectAndGetObject(c *C) { - storer, ok := s.Storer.(core.Transactioner) + storer, ok := s.Storer.(storer.Transactioner) if !ok { - c.Skip("not a core.ObjectStorerTx") + c.Skip("not a plumbing.ObjectStorerTx") } tx := storer.Begin() @@ -182,27 +183,27 @@ func (s *BaseStorageSuite) TestObjectStorerTxSetObjectAndGetObject(c *C) { c.Assert(err, IsNil) c.Assert(h.String(), Equals, expected.Hash) - o, err := tx.Object(expected.Type, core.NewHash(expected.Hash)) + o, err := tx.Object(expected.Type, plumbing.NewHash(expected.Hash)) c.Assert(o.Hash().String(), DeepEquals, expected.Hash) } } func (s *BaseStorageSuite) TestObjectStorerTxGetObjectNotFound(c *C) { - storer, ok := s.Storer.(core.Transactioner) + storer, ok := s.Storer.(storer.Transactioner) if !ok { - c.Skip("not a core.ObjectStorerTx") + c.Skip("not a plumbing.ObjectStorerTx") } tx := storer.Begin() - o, err := tx.Object(core.AnyObject, core.ZeroHash) + o, err := tx.Object(plumbing.AnyObject, plumbing.ZeroHash) c.Assert(o, IsNil) - c.Assert(err, Equals, core.ErrObjectNotFound) + c.Assert(err, Equals, plumbing.ErrObjectNotFound) } func (s *BaseStorageSuite) TestObjectStorerTxSetObjectAndRollback(c *C) { - storer, ok := s.Storer.(core.Transactioner) + storer, ok := s.Storer.(storer.Transactioner) if !ok { - c.Skip("not a core.ObjectStorerTx") + c.Skip("not a plumbing.ObjectStorerTx") } tx := storer.Begin() @@ -215,7 +216,7 @@ func (s *BaseStorageSuite) TestObjectStorerTxSetObjectAndRollback(c *C) { err := tx.Rollback() c.Assert(err, IsNil) - iter, err := s.Storer.IterObjects(core.AnyObject) + iter, err := s.Storer.IterObjects(plumbing.AnyObject) c.Assert(err, IsNil) _, err = iter.Next() c.Assert(err, Equals, io.EOF) @@ -223,29 +224,29 @@ func (s *BaseStorageSuite) TestObjectStorerTxSetObjectAndRollback(c *C) { func (s *BaseStorageSuite) TestSetReferenceAndGetReference(c *C) { err := s.Storer.SetReference( - core.NewReferenceFromStrings("foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"), + plumbing.NewReferenceFromStrings("foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"), ) c.Assert(err, IsNil) err = s.Storer.SetReference( - core.NewReferenceFromStrings("bar", "482e0eada5de4039e6f216b45b3c9b683b83bfa"), + plumbing.NewReferenceFromStrings("bar", "482e0eada5de4039e6f216b45b3c9b683b83bfa"), ) c.Assert(err, IsNil) - e, err := s.Storer.Reference(core.ReferenceName("foo")) + e, err := s.Storer.Reference(plumbing.ReferenceName("foo")) c.Assert(err, IsNil) c.Assert(e.Hash().String(), Equals, "bc9968d75e48de59f0870ffb71f5e160bbbdcf52") } func (s *BaseStorageSuite) TestGetReferenceNotFound(c *C) { - r, err := s.Storer.Reference(core.ReferenceName("bar")) - c.Assert(err, Equals, core.ErrReferenceNotFound) + r, err := s.Storer.Reference(plumbing.ReferenceName("bar")) + c.Assert(err, Equals, plumbing.ErrReferenceNotFound) c.Assert(r, IsNil) } func (s *BaseStorageSuite) TestIterReferences(c *C) { err := s.Storer.SetReference( - core.NewReferenceFromStrings("refs/foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"), + plumbing.NewReferenceFromStrings("refs/foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"), ) c.Assert(err, IsNil) @@ -284,7 +285,7 @@ func (s *BaseStorageSuite) TestSetConfigInvalid(c *C) { c.Assert(err, NotNil) } -func objectEquals(a core.Object, b core.Object) error { +func objectEquals(a plumbing.Object, b plumbing.Object) error { ha := a.Hash() hb := b.Hash() if ha != hb { @@ -7,7 +7,8 @@ import ( "io" "io/ioutil" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" ) // Tag represents an annotated tag object. It points to a single git object of @@ -18,12 +19,12 @@ import ( // // https://git-scm.com/book/en/v2/Git-Internals-Git-References#Tags type Tag struct { - Hash core.Hash + Hash plumbing.Hash Name string Tagger Signature Message string - TargetType core.ObjectType - Target core.Hash + TargetType plumbing.ObjectType + Target plumbing.Hash r *Repository } @@ -32,20 +33,20 @@ type Tag struct { // The returned value will always match the current value of Tag.Hash. // // ID is present to fulfill the Object interface. -func (t *Tag) ID() core.Hash { +func (t *Tag) ID() plumbing.Hash { return t.Hash } -// Type returns the type of object. It always returns core.TagObject. +// Type returns the type of object. It always returns plumbing.TagObject. // // Type is present to fulfill the Object interface. -func (t *Tag) Type() core.ObjectType { - return core.TagObject +func (t *Tag) Type() plumbing.ObjectType { + return plumbing.TagObject } -// Decode transforms a core.Object into a Tag struct. -func (t *Tag) Decode(o core.Object) (err error) { - if o.Type() != core.TagObject { +// Decode transforms a plumbing.Object into a Tag struct. +func (t *Tag) Decode(o plumbing.Object) (err error) { + if o.Type() != plumbing.TagObject { return ErrUnsupportedObject } @@ -72,9 +73,9 @@ func (t *Tag) Decode(o core.Object) (err error) { split := bytes.SplitN(line, []byte{' '}, 2) switch string(split[0]) { case "object": - t.Target = core.NewHash(string(split[1])) + t.Target = plumbing.NewHash(string(split[1])) case "type": - t.TargetType, err = core.ParseObjectType(string(split[1])) + t.TargetType, err = plumbing.ParseObjectType(string(split[1])) if err != nil { return err } @@ -98,9 +99,9 @@ func (t *Tag) Decode(o core.Object) (err error) { return nil } -// Encode transforms a Tag into a core.Object. -func (t *Tag) Encode(o core.Object) error { - o.SetType(core.TagObject) +// Encode transforms a Tag into a plumbing.Object. +func (t *Tag) Encode(o plumbing.Object) error { + o.SetType(plumbing.TagObject) w, err := o.Writer() if err != nil { return err @@ -131,7 +132,7 @@ func (t *Tag) Encode(o core.Object) error { // Commit returns the commit pointed to by the tag. If the tag points to a // different type of object ErrUnsupportedObject will be returned. func (t *Tag) Commit() (*Commit, error) { - if t.TargetType != core.CommitObject { + if t.TargetType != plumbing.CommitObject { return nil, ErrUnsupportedObject } return t.r.Commit(t.Target) @@ -142,13 +143,13 @@ func (t *Tag) Commit() (*Commit, error) { // to a commit or tree object ErrUnsupportedObject will be returned. func (t *Tag) Tree() (*Tree, error) { switch t.TargetType { - case core.CommitObject: + case plumbing.CommitObject: commit, err := t.r.Commit(t.Target) if err != nil { return nil, err } return commit.Tree() - case core.TreeObject: + case plumbing.TreeObject: return t.r.Tree(t.Target) default: return nil, ErrUnsupportedObject @@ -158,7 +159,7 @@ func (t *Tag) Tree() (*Tree, error) { // Blob returns the blob pointed to by the tag. If the tag points to a // different type of object ErrUnsupportedObject will be returned. func (t *Tag) Blob() (*Blob, error) { - if t.TargetType != core.BlobObject { + if t.TargetType != plumbing.BlobObject { return nil, ErrUnsupportedObject } return t.r.Blob(t.Target) @@ -176,14 +177,14 @@ func (t *Tag) String() string { return fmt.Sprintf( "%s %s\nTagger: %s\nDate: %s\n\n%s\n%s", - core.TagObject, t.Name, t.Tagger.String(), t.Tagger.When.Format(DateFormat), + plumbing.TagObject, t.Name, t.Tagger.String(), t.Tagger.When.Format(DateFormat), t.Message, objectAsString(obj), ) } // TagIter provides an iterator for a set of tags. type TagIter struct { - core.ObjectIter + storer.ObjectIter r *Repository } @@ -191,7 +192,7 @@ type TagIter struct { // object iterator. // // The returned TagIter will automatically skip over non-tag objects. -func NewTagIter(r *Repository, iter core.ObjectIter) *TagIter { +func NewTagIter(r *Repository, iter storer.ObjectIter) *TagIter { return &TagIter{iter, r} } @@ -211,7 +212,7 @@ func (iter *TagIter) Next() (*Tag, error) { // an error happends or the end of the iter is reached. If ErrStop is sent // the iteration is stop but no error is returned. The iterator is closed. func (iter *TagIter) ForEach(cb func(*Tag) error) error { - return iter.ObjectIter.ForEach(func(obj core.Object) error { + return iter.ObjectIter.ForEach(func(obj plumbing.Object) error { tag := &Tag{r: iter.r} if err := tag.Decode(obj); err != nil { return err diff --git a/tag_test.go b/tag_test.go index aaedebe..652577b 100644 --- a/tag_test.go +++ b/tag_test.go @@ -5,8 +5,8 @@ import ( "time" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" + "gopkg.in/src-d/go-git.v4/plumbing" ) type TagSuite struct { @@ -23,7 +23,7 @@ func (s *TagSuite) SetUpSuite(c *C) { func (s *TagSuite) TestName(c *C) { r := s.Repositories["https://github.com/git-fixtures/tags.git"] - tag, err := r.Tag(core.NewHash("b742a2a9fa0afcfa9a6fad080980fbc26b007c69")) + tag, err := r.Tag(plumbing.NewHash("b742a2a9fa0afcfa9a6fad080980fbc26b007c69")) c.Assert(err, IsNil) c.Assert(tag.Name, Equals, "annotated-tag") } @@ -31,7 +31,7 @@ func (s *TagSuite) TestName(c *C) { func (s *TagSuite) TestTagger(c *C) { r := s.Repositories["https://github.com/git-fixtures/tags.git"] - tag, err := r.Tag(core.NewHash("b742a2a9fa0afcfa9a6fad080980fbc26b007c69")) + tag, err := r.Tag(plumbing.NewHash("b742a2a9fa0afcfa9a6fad080980fbc26b007c69")) c.Assert(err, IsNil) c.Assert(tag.Tagger.String(), Equals, "Máximo Cuadros <mcuadros@gmail.com>") } @@ -39,83 +39,83 @@ func (s *TagSuite) TestTagger(c *C) { func (s *TagSuite) TestAnnotated(c *C) { r := s.Repositories["https://github.com/git-fixtures/tags.git"] - tag, err := r.Tag(core.NewHash("b742a2a9fa0afcfa9a6fad080980fbc26b007c69")) + tag, err := r.Tag(plumbing.NewHash("b742a2a9fa0afcfa9a6fad080980fbc26b007c69")) c.Assert(err, IsNil) c.Assert(tag.Message, Equals, "example annotated tag\n") commit, err := tag.Commit() c.Assert(err, IsNil) - c.Assert(commit.Type(), Equals, core.CommitObject) + c.Assert(commit.Type(), Equals, plumbing.CommitObject) c.Assert(commit.ID().String(), Equals, "f7b877701fbf855b44c0a9e86f3fdce2c298b07f") } func (s *TagSuite) TestCommit(c *C) { r := s.Repositories["https://github.com/git-fixtures/tags.git"] - tag, err := r.Tag(core.NewHash("ad7897c0fb8e7d9a9ba41fa66072cf06095a6cfc")) + tag, err := r.Tag(plumbing.NewHash("ad7897c0fb8e7d9a9ba41fa66072cf06095a6cfc")) c.Assert(err, IsNil) c.Assert(tag.Message, Equals, "a tagged commit\n") commit, err := tag.Commit() c.Assert(err, IsNil) - c.Assert(commit.Type(), Equals, core.CommitObject) + c.Assert(commit.Type(), Equals, plumbing.CommitObject) c.Assert(commit.ID().String(), Equals, "f7b877701fbf855b44c0a9e86f3fdce2c298b07f") } func (s *TagSuite) TestBlob(c *C) { r := s.Repositories["https://github.com/git-fixtures/tags.git"] - tag, err := r.Tag(core.NewHash("fe6cb94756faa81e5ed9240f9191b833db5f40ae")) + tag, err := r.Tag(plumbing.NewHash("fe6cb94756faa81e5ed9240f9191b833db5f40ae")) c.Assert(err, IsNil) c.Assert(tag.Message, Equals, "a tagged blob\n") blob, err := tag.Blob() c.Assert(err, IsNil) - c.Assert(blob.Type(), Equals, core.BlobObject) + c.Assert(blob.Type(), Equals, plumbing.BlobObject) c.Assert(blob.ID().String(), Equals, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391") } func (s *TagSuite) TestTree(c *C) { r := s.Repositories["https://github.com/git-fixtures/tags.git"] - tag, err := r.Tag(core.NewHash("152175bf7e5580299fa1f0ba41ef6474cc043b70")) + tag, err := r.Tag(plumbing.NewHash("152175bf7e5580299fa1f0ba41ef6474cc043b70")) c.Assert(err, IsNil) c.Assert(tag.Message, Equals, "a tagged tree\n") tree, err := tag.Tree() c.Assert(err, IsNil) - c.Assert(tree.Type(), Equals, core.TreeObject) + c.Assert(tree.Type(), Equals, plumbing.TreeObject) c.Assert(tree.ID().String(), Equals, "70846e9a10ef7b41064b40f07713d5b8b9a8fc73") } func (s *TagSuite) TestTreeFromCommit(c *C) { r := s.Repositories["https://github.com/git-fixtures/tags.git"] - tag, err := r.Tag(core.NewHash("ad7897c0fb8e7d9a9ba41fa66072cf06095a6cfc")) + tag, err := r.Tag(plumbing.NewHash("ad7897c0fb8e7d9a9ba41fa66072cf06095a6cfc")) c.Assert(err, IsNil) c.Assert(tag.Message, Equals, "a tagged commit\n") tree, err := tag.Tree() c.Assert(err, IsNil) - c.Assert(tree.Type(), Equals, core.TreeObject) + c.Assert(tree.Type(), Equals, plumbing.TreeObject) c.Assert(tree.ID().String(), Equals, "70846e9a10ef7b41064b40f07713d5b8b9a8fc73") } func (s *TagSuite) TestObject(c *C) { r := s.Repositories["https://github.com/git-fixtures/tags.git"] - tag, err := r.Tag(core.NewHash("ad7897c0fb8e7d9a9ba41fa66072cf06095a6cfc")) + tag, err := r.Tag(plumbing.NewHash("ad7897c0fb8e7d9a9ba41fa66072cf06095a6cfc")) c.Assert(err, IsNil) obj, err := tag.Object() c.Assert(err, IsNil) - c.Assert(obj.Type(), Equals, core.CommitObject) + c.Assert(obj.Type(), Equals, plumbing.CommitObject) c.Assert(obj.ID().String(), Equals, "f7b877701fbf855b44c0a9e86f3fdce2c298b07f") } func (s *TagSuite) TestTagItter(c *C) { r := s.Repositories["https://github.com/git-fixtures/tags.git"] - iter, err := r.s.IterObjects(core.TagObject) + iter, err := r.s.IterObjects(plumbing.TagObject) c.Assert(err, IsNil) var count int @@ -131,7 +131,7 @@ func (s *TagSuite) TestTagItter(c *C) { func (s *TagSuite) TestTagIterError(c *C) { r := s.Repositories["https://github.com/git-fixtures/tags.git"] - iter, err := r.s.IterObjects(core.TagObject) + iter, err := r.s.IterObjects(plumbing.TagObject) c.Assert(err, IsNil) i := NewTagIter(r, iter) @@ -150,18 +150,18 @@ func (s *TagSuite) TestTagEncodeDecodeIdempotent(c *C) { Name: "foo", Tagger: Signature{Name: "Foo", Email: "foo@example.local", When: ts}, Message: "Message\n\nFoo\nBar\nBaz\n\n", - TargetType: core.BlobObject, - Target: core.NewHash("b029517f6300c2da0f4b651b8642506cd6aaf45d"), + TargetType: plumbing.BlobObject, + Target: plumbing.NewHash("b029517f6300c2da0f4b651b8642506cd6aaf45d"), }, { Name: "foo", Tagger: Signature{Name: "Foo", Email: "foo@example.local", When: ts}, - TargetType: core.BlobObject, - Target: core.NewHash("b029517f6300c2da0f4b651b8642506cd6aaf45d"), + TargetType: plumbing.BlobObject, + Target: plumbing.NewHash("b029517f6300c2da0f4b651b8642506cd6aaf45d"), }, } for _, tag := range tags { - obj := &core.MemoryObject{} + obj := &plumbing.MemoryObject{} err = tag.Encode(obj) c.Assert(err, IsNil) newTag := &Tag{} @@ -175,7 +175,7 @@ func (s *TagSuite) TestTagEncodeDecodeIdempotent(c *C) { func (s *TagSuite) TestString(c *C) { r := s.Repositories["https://github.com/git-fixtures/tags.git"] - tag, err := r.Tag(core.NewHash("b742a2a9fa0afcfa9a6fad080980fbc26b007c69")) + tag, err := r.Tag(plumbing.NewHash("b742a2a9fa0afcfa9a6fad080980fbc26b007c69")) c.Assert(err, IsNil) c.Assert(tag.String(), Equals, ""+ "tag annotated-tag\n"+ @@ -10,7 +10,8 @@ import ( "strconv" "strings" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/storer" ) const ( @@ -30,7 +31,7 @@ var ( // and/or blobs (i.e. files and sub-directories) type Tree struct { Entries []TreeEntry - Hash core.Hash + Hash plumbing.Hash r *Repository m map[string]*TreeEntry @@ -40,7 +41,7 @@ type Tree struct { type TreeEntry struct { Name string Mode os.FileMode - Hash core.Hash + Hash plumbing.Hash } // File returns the hash of the file identified by the `path` argument. @@ -51,7 +52,7 @@ func (t *Tree) File(path string) (*File, error) { return nil, ErrFileNotFound } - obj, err := t.r.s.Object(core.BlobObject, e.Hash) + obj, err := t.r.s.Object(plumbing.BlobObject, e.Hash) if err != nil { return nil, err } @@ -84,7 +85,7 @@ func (t *Tree) dir(baseName string) (*Tree, error) { return nil, errDirNotFound } - obj, err := t.r.s.Object(core.TreeObject, entry.Hash) + obj, err := t.r.s.Object(plumbing.TreeObject, entry.Hash) if err != nil { return nil, err } @@ -118,18 +119,18 @@ func (t *Tree) Files() *FileIter { // the current value of Tree.Hash. // // ID is present to fulfill the Object interface. -func (t *Tree) ID() core.Hash { +func (t *Tree) ID() plumbing.Hash { return t.Hash } -// Type returns the type of object. It always returns core.TreeObject. -func (t *Tree) Type() core.ObjectType { - return core.TreeObject +// Type returns the type of object. It always returns plumbing.TreeObject. +func (t *Tree) Type() plumbing.ObjectType { + return plumbing.TreeObject } -// Decode transform an core.Object into a Tree struct -func (t *Tree) Decode(o core.Object) (err error) { - if o.Type() != core.TreeObject { +// Decode transform an plumbing.Object into a Tree struct +func (t *Tree) Decode(o plumbing.Object) (err error) { + if o.Type() != plumbing.TreeObject { return ErrUnsupportedObject } @@ -168,7 +169,7 @@ func (t *Tree) Decode(o core.Object) (err error) { return err } - var hash core.Hash + var hash plumbing.Hash if _, err = io.ReadFull(r, hash[:]); err != nil { return err } @@ -201,9 +202,9 @@ func (t *Tree) decodeFileMode(mode string) (os.FileMode, error) { return m, nil } -// Encode transforms a Tree into a core.Object. -func (t *Tree) Encode(o core.Object) error { - o.SetType(core.TreeObject) +// Encode transforms a Tree into a plumbing.Object. +func (t *Tree) Encode(o plumbing.Object) error { + o.SetType(plumbing.TreeObject) w, err := o.Writer() if err != nil { return err @@ -371,7 +372,7 @@ func (w *TreeWalker) Close() { // TreeIter provides an iterator for a set of trees. type TreeIter struct { - core.ObjectIter + storer.ObjectIter r *Repository } @@ -379,7 +380,7 @@ type TreeIter struct { // object iterator. // // The returned TreeIter will automatically skip over non-tree objects. -func NewTreeIter(r *Repository, iter core.ObjectIter) *TreeIter { +func NewTreeIter(r *Repository, iter storer.ObjectIter) *TreeIter { return &TreeIter{iter, r} } @@ -392,7 +393,7 @@ func (iter *TreeIter) Next() (*Tree, error) { return nil, err } - if obj.Type() != core.TreeObject { + if obj.Type() != plumbing.TreeObject { continue } @@ -405,8 +406,8 @@ func (iter *TreeIter) Next() (*Tree, error) { // an error happens or the end of the iter is reached. If ErrStop is sent // the iteration is stop but no error is returned. The iterator is closed. func (iter *TreeIter) ForEach(cb func(*Tree) error) error { - return iter.ObjectIter.ForEach(func(obj core.Object) error { - if obj.Type() != core.TreeObject { + return iter.ObjectIter.ForEach(func(obj plumbing.Object) error { + if obj.Type() != plumbing.TreeObject { return nil } diff --git a/tree_diff.go b/tree_diff.go index 1f5f076..d5f0377 100644 --- a/tree_diff.go +++ b/tree_diff.go @@ -7,7 +7,7 @@ import ( "sort" "strings" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) type Action int @@ -250,10 +250,10 @@ func hasChange(a, b *Tree, path string) (bool, error) { return ha != hb, nil } -func hash(tree *Tree, path string) (core.Hash, error) { +func hash(tree *Tree, path string) (plumbing.Hash, error) { file, err := tree.File(path) if err != nil { - var empty core.Hash + var empty plumbing.Hash return empty, fmt.Errorf("cannot find file %s in tree: %s", path, err) } diff --git a/tree_diff_test.go b/tree_diff_test.go index 58f0a29..81fee5d 100644 --- a/tree_diff_test.go +++ b/tree_diff_test.go @@ -3,8 +3,8 @@ package git import ( "sort" - "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/fixtures" + "gopkg.in/src-d/go-git.v4/plumbing" . "gopkg.in/check.v1" ) @@ -42,13 +42,13 @@ func (s *DiffTreeSuite) TestActionString(c *C) { } func (s *DiffTreeSuite) TestChangeFilesInsert(c *C) { - tree, err := s.Repository.Tree(core.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")) + tree, err := s.Repository.Tree(plumbing.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")) c.Assert(err, IsNil) change := &Change{Action: Insert} change.To.Name = "json/long.json" change.To.Tree = tree - change.To.TreeEntry.Hash = core.NewHash("49c6bb89b17060d7b4deacb7b338fcc6ea2352a9") + change.To.TreeEntry.Hash = plumbing.NewHash("49c6bb89b17060d7b4deacb7b338fcc6ea2352a9") from, to, err := change.Files() c.Assert(err, IsNil) @@ -57,13 +57,13 @@ func (s *DiffTreeSuite) TestChangeFilesInsert(c *C) { } func (s *DiffTreeSuite) TestChangeFilesDelete(c *C) { - tree, err := s.Repository.Tree(core.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")) + tree, err := s.Repository.Tree(plumbing.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")) c.Assert(err, IsNil) change := &Change{Action: Delete} change.From.Name = "json/long.json" change.From.Tree = tree - change.From.TreeEntry.Hash = core.NewHash("49c6bb89b17060d7b4deacb7b338fcc6ea2352a9") + change.From.TreeEntry.Hash = plumbing.NewHash("49c6bb89b17060d7b4deacb7b338fcc6ea2352a9") from, to, err := change.Files() c.Assert(err, IsNil) @@ -72,16 +72,16 @@ func (s *DiffTreeSuite) TestChangeFilesDelete(c *C) { } func (s *DiffTreeSuite) TestChangeFilesModify(c *C) { - tree, err := s.Repository.Tree(core.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")) + tree, err := s.Repository.Tree(plumbing.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")) c.Assert(err, IsNil) change := &Change{Action: Modify} change.To.Name = "json/long.json" change.To.Tree = tree - change.To.TreeEntry.Hash = core.NewHash("49c6bb89b17060d7b4deacb7b338fcc6ea2352a9") + change.To.TreeEntry.Hash = plumbing.NewHash("49c6bb89b17060d7b4deacb7b338fcc6ea2352a9") change.From.Name = "json/long.json" change.From.Tree = tree - change.From.TreeEntry.Hash = core.NewHash("9a48f23120e880dfbe41f7c9b7b708e9ee62a492") + change.From.TreeEntry.Hash = plumbing.NewHash("9a48f23120e880dfbe41f7c9b7b708e9ee62a492") from, to, err := change.Files() c.Assert(err, IsNil) @@ -410,7 +410,7 @@ func tree(repo *Repository, commitHashStr string) (*Tree, error) { return nil, nil } - commit, err := repo.Commit(core.NewHash(commitHashStr)) + commit, err := repo.Commit(plumbing.NewHash(commitHashStr)) if err != nil { return nil, err } diff --git a/tree_test.go b/tree_test.go index 237363d..6e12ceb 100644 --- a/tree_test.go +++ b/tree_test.go @@ -4,7 +4,7 @@ import ( "io" "os" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" . "gopkg.in/check.v1" ) @@ -18,7 +18,7 @@ var _ = Suite(&TreeSuite{}) func (s *TreeSuite) SetUpSuite(c *C) { s.BaseSuite.SetUpSuite(c) - hash := core.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c") + hash := plumbing.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c") var err error s.Tree, err = s.Repository.Tree(hash) @@ -36,8 +36,8 @@ func (s *TreeSuite) TestDecode(c *C) { } func (s *TreeSuite) TestDecodeNonTree(c *C) { - hash := core.NewHash("9a48f23120e880dfbe41f7c9b7b708e9ee62a492") - blob, err := s.Repository.s.Object(core.BlobObject, hash) + hash := plumbing.NewHash("9a48f23120e880dfbe41f7c9b7b708e9ee62a492") + blob, err := s.Repository.s.Object(plumbing.BlobObject, hash) c.Assert(err, IsNil) tree := &Tree{} @@ -46,7 +46,7 @@ func (s *TreeSuite) TestDecodeNonTree(c *C) { } func (s *TreeSuite) TestType(c *C) { - c.Assert(s.Tree.Type(), Equals, core.TreeObject) + c.Assert(s.Tree.Type(), Equals, plumbing.TreeObject) } func (s *TreeSuite) TestFile(c *C) { @@ -72,23 +72,23 @@ func (s *TreeSuite) TestFiles(c *C) { c.Assert(count, Equals, 9) } -// This core.Object implementation has a reader that only returns 6 +// This plumbing.Object implementation has a reader that only returns 6 // bytes at a time, this should simulate the conditions when a read // returns less bytes than asked, for example when reading a hash which // is bigger than 6 bytes. type SortReadObject struct { - t core.ObjectType - h core.Hash + t plumbing.ObjectType + h plumbing.Hash cont []byte sz int64 } -func (o *SortReadObject) Hash() core.Hash { return o.h } -func (o *SortReadObject) Type() core.ObjectType { return o.t } -func (o *SortReadObject) SetType(t core.ObjectType) { o.t = t } -func (o *SortReadObject) Size() int64 { return o.sz } -func (o *SortReadObject) SetSize(s int64) { o.sz = s } -func (o *SortReadObject) Content() []byte { return o.cont } +func (o *SortReadObject) Hash() plumbing.Hash { return o.h } +func (o *SortReadObject) Type() plumbing.ObjectType { return o.t } +func (o *SortReadObject) SetType(t plumbing.ObjectType) { o.t = t } +func (o *SortReadObject) Size() int64 { return o.sz } +func (o *SortReadObject) SetSize(s int64) { o.sz = s } +func (o *SortReadObject) Content() []byte { return o.cont } func (o *SortReadObject) Reader() (io.ReadCloser, error) { return &SortReadCloser{pos: 0, data: o.cont}, nil } @@ -128,14 +128,14 @@ func (s *TreeSuite) TestTreeDecodeEncodeIdempotent(c *C) { trees := []*Tree{ { Entries: []TreeEntry{ - {"foo", os.FileMode(0), core.NewHash("b029517f6300c2da0f4b651b8642506cd6aaf45d")}, - {"bar", os.FileMode(0), core.NewHash("c029517f6300c2da0f4b651b8642506cd6aaf45d")}, - {"baz", os.FileMode(0), core.NewHash("d029517f6300c2da0f4b651b8642506cd6aaf45d")}, + {"foo", os.FileMode(0), plumbing.NewHash("b029517f6300c2da0f4b651b8642506cd6aaf45d")}, + {"bar", os.FileMode(0), plumbing.NewHash("c029517f6300c2da0f4b651b8642506cd6aaf45d")}, + {"baz", os.FileMode(0), plumbing.NewHash("d029517f6300c2da0f4b651b8642506cd6aaf45d")}, }, }, } for _, tree := range trees { - obj := &core.MemoryObject{} + obj := &plumbing.MemoryObject{} err := tree.Encode(obj) c.Assert(err, IsNil) newTree := &Tree{} @@ -181,7 +181,7 @@ func (s *TreeSuite) TestTreeIter(c *C) { func (s *TreeSuite) TestTreeWalkerNext(c *C) { r := s.Repository - commit, err := r.Commit(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + commit, err := r.Commit(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) c.Assert(err, IsNil) tree, err := commit.Tree() @@ -206,7 +206,7 @@ func (s *TreeSuite) TestTreeWalkerNext(c *C) { func (s *TreeSuite) TestTreeWalkerNextNonRecursive(c *C) { r := s.Repository - commit, err := r.Commit(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + commit, err := r.Commit(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) c.Assert(err, IsNil) tree, err := commit.Tree() @@ -844,8 +844,8 @@ func (s *TreeSuite) TestTreeDecodeReadBug(c *C) { 0xf0, 0xd2, 0x87, } obj := &SortReadObject{ - t: core.TreeObject, - h: core.ZeroHash, + t: plumbing.TreeObject, + h: plumbing.ZeroHash, cont: cont, sz: 5313, } @@ -854,570 +854,570 @@ func (s *TreeSuite) TestTreeDecodeReadBug(c *C) { Entries: []TreeEntry{ { Name: "alter.c", Mode: 0x81a4, - Hash: core.Hash{0xa4, 0x9d, 0x33, 0x49, 0xd7, 0xe2, 0x3f, 0xb5, 0x81, 0x19, 0x4f, 0x4c, 0xb5, 0x9a, 0xc0, 0xd5, 0x1b, 0x2, 0x1f, 0x78}, + Hash: plumbing.Hash{0xa4, 0x9d, 0x33, 0x49, 0xd7, 0xe2, 0x3f, 0xb5, 0x81, 0x19, 0x4f, 0x4c, 0xb5, 0x9a, 0xc0, 0xd5, 0x1b, 0x2, 0x1f, 0x78}, }, { Name: "analyze.c", Mode: 0x81a4, - Hash: core.Hash{0x9a, 0x3e, 0x95, 0x97, 0xdb, 0xb, 0x3, 0x20, 0x77, 0xc9, 0x1d, 0x96, 0x9d, 0x22, 0xc6, 0x27, 0x3f, 0x70, 0x2a, 0xc}, + Hash: plumbing.Hash{0x9a, 0x3e, 0x95, 0x97, 0xdb, 0xb, 0x3, 0x20, 0x77, 0xc9, 0x1d, 0x96, 0x9d, 0x22, 0xc6, 0x27, 0x3f, 0x70, 0x2a, 0xc}, }, { Name: "attach.c", Mode: 0x81a4, - Hash: core.Hash{0xb8, 0xe1, 0x21, 0x99, 0xb5, 0x7d, 0xe8, 0x11, 0xea, 0xe0, 0xd0, 0x61, 0x42, 0xd5, 0xac, 0x4f, 0xd4, 0x30, 0xb1, 0xd8}, + Hash: plumbing.Hash{0xb8, 0xe1, 0x21, 0x99, 0xb5, 0x7d, 0xe8, 0x11, 0xea, 0xe0, 0xd0, 0x61, 0x42, 0xd5, 0xac, 0x4f, 0xd4, 0x30, 0xb1, 0xd8}, }, { Name: "auth.c", Mode: 0x81a4, - Hash: core.Hash{0xd3, 0x8b, 0xb8, 0x36, 0xa7, 0x84, 0xfb, 0xfa, 0xb6, 0xab, 0x7b, 0x3, 0xd4, 0xe6, 0xdd, 0x43, 0xed, 0xc4, 0x1f, 0xa7}, + Hash: plumbing.Hash{0xd3, 0x8b, 0xb8, 0x36, 0xa7, 0x84, 0xfb, 0xfa, 0xb6, 0xab, 0x7b, 0x3, 0xd4, 0xe6, 0xdd, 0x43, 0xed, 0xc4, 0x1f, 0xa7}, }, { Name: "backup.c", Mode: 0x81a4, - Hash: core.Hash{0x25, 0x2f, 0x61, 0xcf, 0xca, 0xa8, 0xfc, 0xf3, 0x13, 0x7e, 0x8, 0xed, 0x68, 0x47, 0xdc, 0xfe, 0x1d, 0xc1, 0xde, 0x54}, + Hash: plumbing.Hash{0x25, 0x2f, 0x61, 0xcf, 0xca, 0xa8, 0xfc, 0xf3, 0x13, 0x7e, 0x8, 0xed, 0x68, 0x47, 0xdc, 0xfe, 0x1d, 0xc1, 0xde, 0x54}, }, { Name: "bitvec.c", Mode: 0x81a4, - Hash: core.Hash{0x52, 0x18, 0x4a, 0xa9, 0x64, 0xce, 0x18, 0x98, 0xf3, 0x5d, 0x1b, 0x3d, 0x87, 0x87, 0x1c, 0x2d, 0xe, 0xf4, 0xc5, 0x3d}, + Hash: plumbing.Hash{0x52, 0x18, 0x4a, 0xa9, 0x64, 0xce, 0x18, 0x98, 0xf3, 0x5d, 0x1b, 0x3d, 0x87, 0x87, 0x1c, 0x2d, 0xe, 0xf4, 0xc5, 0x3d}, }, { Name: "btmutex.c", Mode: 0x81a4, - Hash: core.Hash{0xd8, 0x7d, 0x4d, 0x5f, 0xee, 0xb6, 0x30, 0x7a, 0xec, 0xdc, 0x9a, 0x83, 0x11, 0x14, 0x89, 0xab, 0x30, 0xc6, 0x78, 0xc3}, + Hash: plumbing.Hash{0xd8, 0x7d, 0x4d, 0x5f, 0xee, 0xb6, 0x30, 0x7a, 0xec, 0xdc, 0x9a, 0x83, 0x11, 0x14, 0x89, 0xab, 0x30, 0xc6, 0x78, 0xc3}, }, { Name: "btree.c", Mode: 0x81a4, - Hash: core.Hash{0x3c, 0xa6, 0x5, 0x83, 0xe3, 0xc8, 0xe3, 0x12, 0x0, 0xf9, 0x73, 0xe0, 0xe9, 0xc4, 0x53, 0x62, 0x58, 0xb2, 0x64, 0x39}, + Hash: plumbing.Hash{0x3c, 0xa6, 0x5, 0x83, 0xe3, 0xc8, 0xe3, 0x12, 0x0, 0xf9, 0x73, 0xe0, 0xe9, 0xc4, 0x53, 0x62, 0x58, 0xb2, 0x64, 0x39}, }, { Name: "btree.h", Mode: 0x81a4, - Hash: core.Hash{0xac, 0xe0, 0xf8, 0xcd, 0x21, 0x77, 0x70, 0xa2, 0xf6, 0x6b, 0x2e, 0xb8, 0x71, 0xbb, 0xc5, 0xfd, 0xc6, 0xfc, 0x2b, 0x68}, + Hash: plumbing.Hash{0xac, 0xe0, 0xf8, 0xcd, 0x21, 0x77, 0x70, 0xa2, 0xf6, 0x6b, 0x2e, 0xb8, 0x71, 0xbb, 0xc5, 0xfd, 0xc6, 0xfc, 0x2b, 0x68}, }, { Name: "btreeInt.h", Mode: 0x81a4, - Hash: core.Hash{0xce, 0x3c, 0x54, 0x93, 0xf8, 0xca, 0xd0, 0xbc, 0x54, 0x8a, 0xe8, 0xe4, 0x4e, 0x51, 0x28, 0x31, 0xd8, 0xfa, 0xc4, 0x31}, + Hash: plumbing.Hash{0xce, 0x3c, 0x54, 0x93, 0xf8, 0xca, 0xd0, 0xbc, 0x54, 0x8a, 0xe8, 0xe4, 0x4e, 0x51, 0x28, 0x31, 0xd8, 0xfa, 0xc4, 0x31}, }, { Name: "build.c", Mode: 0x81a4, - Hash: core.Hash{0x3c, 0x91, 0xcd, 0xcf, 0xdb, 0x7b, 0x1, 0x7c, 0xbc, 0x2d, 0x5c, 0x29, 0x57, 0x1a, 0x98, 0x27, 0xd, 0xe0, 0x71, 0xe6}, + Hash: plumbing.Hash{0x3c, 0x91, 0xcd, 0xcf, 0xdb, 0x7b, 0x1, 0x7c, 0xbc, 0x2d, 0x5c, 0x29, 0x57, 0x1a, 0x98, 0x27, 0xd, 0xe0, 0x71, 0xe6}, }, { Name: "callback.c", Mode: 0x81a4, - Hash: core.Hash{0xd4, 0xc, 0x65, 0xcb, 0x92, 0x45, 0x80, 0x29, 0x6a, 0xd0, 0x69, 0xa0, 0x4b, 0xf9, 0xc9, 0xe9, 0x53, 0x4e, 0xca, 0xa7}, + Hash: plumbing.Hash{0xd4, 0xc, 0x65, 0xcb, 0x92, 0x45, 0x80, 0x29, 0x6a, 0xd0, 0x69, 0xa0, 0x4b, 0xf9, 0xc9, 0xe9, 0x53, 0x4e, 0xca, 0xa7}, }, { Name: "complete.c", Mode: 0x81a4, - Hash: core.Hash{0x9e, 0x91, 0x40, 0x8, 0x5c, 0x0, 0x46, 0xed, 0x3b, 0xf6, 0xf4, 0x48, 0x52, 0x20, 0x69, 0x2d, 0xca, 0x17, 0x43, 0xc5}, + Hash: plumbing.Hash{0x9e, 0x91, 0x40, 0x8, 0x5c, 0x0, 0x46, 0xed, 0x3b, 0xf6, 0xf4, 0x48, 0x52, 0x20, 0x69, 0x2d, 0xca, 0x17, 0x43, 0xc5}, }, { Name: "crypto.c", Mode: 0x81a4, - Hash: core.Hash{0x25, 0x51, 0xe6, 0xba, 0x2, 0x39, 0xf8, 0x5a, 0x35, 0x77, 0x96, 0xa8, 0xdd, 0xa8, 0xca, 0x3e, 0x29, 0x70, 0x93, 0xf8}, + Hash: plumbing.Hash{0x25, 0x51, 0xe6, 0xba, 0x2, 0x39, 0xf8, 0x5a, 0x35, 0x77, 0x96, 0xa8, 0xdd, 0xa8, 0xca, 0x3e, 0x29, 0x70, 0x93, 0xf8}, }, { Name: "crypto.h", Mode: 0x81a4, - Hash: core.Hash{0xf7, 0x1f, 0x53, 0x2c, 0xdc, 0x44, 0x8f, 0xa, 0x1d, 0xd5, 0xc6, 0xef, 0xf5, 0xfb, 0xd3, 0x3a, 0x91, 0x55, 0xaa, 0x97}, + Hash: plumbing.Hash{0xf7, 0x1f, 0x53, 0x2c, 0xdc, 0x44, 0x8f, 0xa, 0x1d, 0xd5, 0xc6, 0xef, 0xf5, 0xfb, 0xd3, 0x3a, 0x91, 0x55, 0xaa, 0x97}, }, { Name: "crypto_cc.c", Mode: 0x81a4, - Hash: core.Hash{0x53, 0x7d, 0xf7, 0xe3, 0xb3, 0x6a, 0xb5, 0xcf, 0xdd, 0x6f, 0xca, 0x40, 0x28, 0xeb, 0xca, 0xe1, 0x86, 0x87, 0xd6, 0x4d}, + Hash: plumbing.Hash{0x53, 0x7d, 0xf7, 0xe3, 0xb3, 0x6a, 0xb5, 0xcf, 0xdd, 0x6f, 0xca, 0x40, 0x28, 0xeb, 0xca, 0xe1, 0x86, 0x87, 0xd6, 0x4d}, }, { Name: "crypto_impl.c", Mode: 0x81a4, - Hash: core.Hash{0xa5, 0x89, 0x27, 0xc7, 0x6e, 0xf6, 0x20, 0x56, 0x77, 0xbe, 0x5c, 0x1a, 0x8e, 0x80, 0xc9, 0x83, 0x56, 0xb3, 0xa9, 0xd3}, + Hash: plumbing.Hash{0xa5, 0x89, 0x27, 0xc7, 0x6e, 0xf6, 0x20, 0x56, 0x77, 0xbe, 0x5c, 0x1a, 0x8e, 0x80, 0xc9, 0x83, 0x56, 0xb3, 0xa9, 0xd3}, }, { Name: "crypto_libtomcrypt.c", Mode: 0x81a4, - Hash: core.Hash{0x1a, 0x33, 0x83, 0xe0, 0x1, 0xa7, 0x21, 0x11, 0xc3, 0xf6, 0x61, 0x92, 0x22, 0xb0, 0x65, 0xf4, 0xbd, 0x1, 0xb, 0xe1}, + Hash: plumbing.Hash{0x1a, 0x33, 0x83, 0xe0, 0x1, 0xa7, 0x21, 0x11, 0xc3, 0xf6, 0x61, 0x92, 0x22, 0xb0, 0x65, 0xf4, 0xbd, 0x1, 0xb, 0xe1}, }, { Name: "crypto_openssl.c", Mode: 0x81a4, - Hash: core.Hash{0xd0, 0x19, 0x81, 0x3b, 0x47, 0x6c, 0x52, 0xd0, 0x20, 0xe2, 0xc0, 0xac, 0xd5, 0x24, 0xe9, 0xea, 0x3d, 0xf, 0xb9, 0xfe}, + Hash: plumbing.Hash{0xd0, 0x19, 0x81, 0x3b, 0x47, 0x6c, 0x52, 0xd0, 0x20, 0xe2, 0xc0, 0xac, 0xd5, 0x24, 0xe9, 0xea, 0x3d, 0xf, 0xb9, 0xfe}, }, { Name: "ctime.c", Mode: 0x81a4, - Hash: core.Hash{0x60, 0x59, 0x5f, 0xf8, 0x8d, 0x92, 0xf7, 0x8, 0x26, 0x4, 0xfb, 0xd9, 0xdf, 0x9a, 0xfe, 0xa1, 0x6a, 0xe8, 0x6f, 0xf}, + Hash: plumbing.Hash{0x60, 0x59, 0x5f, 0xf8, 0x8d, 0x92, 0xf7, 0x8, 0x26, 0x4, 0xfb, 0xd9, 0xdf, 0x9a, 0xfe, 0xa1, 0x6a, 0xe8, 0x6f, 0xf}, }, { Name: "date.c", Mode: 0x81a4, - Hash: core.Hash{0x75, 0x8d, 0xd7, 0xc8, 0x9b, 0xca, 0x39, 0x37, 0xa9, 0xd, 0x70, 0x6e, 0xa9, 0x82, 0xce, 0x3a, 0xcf, 0x11, 0xd1, 0x83}, + Hash: plumbing.Hash{0x75, 0x8d, 0xd7, 0xc8, 0x9b, 0xca, 0x39, 0x37, 0xa9, 0xd, 0x70, 0x6e, 0xa9, 0x82, 0xce, 0x3a, 0xcf, 0x11, 0xd1, 0x83}, }, { Name: "delete.c", Mode: 0x81a4, - Hash: core.Hash{0x63, 0x4e, 0x11, 0x55, 0x63, 0xae, 0x12, 0xba, 0x65, 0x58, 0xcc, 0xc5, 0x12, 0xae, 0xd6, 0x31, 0xc0, 0x66, 0xba, 0xd8}, + Hash: plumbing.Hash{0x63, 0x4e, 0x11, 0x55, 0x63, 0xae, 0x12, 0xba, 0x65, 0x58, 0xcc, 0xc5, 0x12, 0xae, 0xd6, 0x31, 0xc0, 0x66, 0xba, 0xd8}, }, { Name: "expr.c", Mode: 0x81a4, - Hash: core.Hash{0x66, 0x3, 0x97, 0xe0, 0x78, 0xae, 0x48, 0xb2, 0xe7, 0x17, 0x5e, 0x33, 0x85, 0x67, 0x78, 0x19, 0x72, 0x2d, 0xdd, 0x6c}, + Hash: plumbing.Hash{0x66, 0x3, 0x97, 0xe0, 0x78, 0xae, 0x48, 0xb2, 0xe7, 0x17, 0x5e, 0x33, 0x85, 0x67, 0x78, 0x19, 0x72, 0x2d, 0xdd, 0x6c}, }, { Name: "fault.c", Mode: 0x81a4, - Hash: core.Hash{0xc3, 0x2, 0x8c, 0x4f, 0x93, 0x6e, 0xdf, 0x96, 0x71, 0x2d, 0xbe, 0x73, 0xa0, 0x76, 0x62, 0xf0, 0xa2, 0x6b, 0x1d, 0xa}, + Hash: plumbing.Hash{0xc3, 0x2, 0x8c, 0x4f, 0x93, 0x6e, 0xdf, 0x96, 0x71, 0x2d, 0xbe, 0x73, 0xa0, 0x76, 0x62, 0xf0, 0xa2, 0x6b, 0x1d, 0xa}, }, { Name: "fkey.c", Mode: 0x81a4, - Hash: core.Hash{0xac, 0x35, 0xbc, 0x19, 0x4c, 0xde, 0xb1, 0x27, 0x98, 0x9b, 0x9, 0x40, 0x35, 0xce, 0xe0, 0x6f, 0x57, 0x37, 0x6f, 0x5e}, + Hash: plumbing.Hash{0xac, 0x35, 0xbc, 0x19, 0x4c, 0xde, 0xb1, 0x27, 0x98, 0x9b, 0x9, 0x40, 0x35, 0xce, 0xe0, 0x6f, 0x57, 0x37, 0x6f, 0x5e}, }, { Name: "func.c", Mode: 0x81a4, - Hash: core.Hash{0xc0, 0x2f, 0x9, 0x6a, 0xda, 0xd5, 0xbc, 0xe9, 0xac, 0x83, 0xd3, 0x5f, 0xf, 0x46, 0x9, 0xd6, 0xf6, 0xd4, 0x3b, 0xe5}, + Hash: plumbing.Hash{0xc0, 0x2f, 0x9, 0x6a, 0xda, 0xd5, 0xbc, 0xe9, 0xac, 0x83, 0xd3, 0x5f, 0xf, 0x46, 0x9, 0xd6, 0xf6, 0xd4, 0x3b, 0xe5}, }, { Name: "global.c", Mode: 0x81a4, - Hash: core.Hash{0x7b, 0x2, 0xcf, 0x21, 0x30, 0xe0, 0xd1, 0xa7, 0xb8, 0x89, 0xd8, 0x44, 0xc, 0xcc, 0x82, 0x8, 0xf7, 0xb6, 0x7b, 0xf9}, + Hash: plumbing.Hash{0x7b, 0x2, 0xcf, 0x21, 0x30, 0xe0, 0xd1, 0xa7, 0xb8, 0x89, 0xd8, 0x44, 0xc, 0xcc, 0x82, 0x8, 0xf7, 0xb6, 0x7b, 0xf9}, }, { Name: "hash.c", Mode: 0x81a4, - Hash: core.Hash{0xe8, 0x1d, 0xcf, 0x95, 0xe4, 0x38, 0x48, 0xfa, 0x70, 0x86, 0xb7, 0xf7, 0x81, 0xc0, 0x90, 0xad, 0xc7, 0xe6, 0xca, 0x8e}, + Hash: plumbing.Hash{0xe8, 0x1d, 0xcf, 0x95, 0xe4, 0x38, 0x48, 0xfa, 0x70, 0x86, 0xb7, 0xf7, 0x81, 0xc0, 0x90, 0xad, 0xc7, 0xe6, 0xca, 0x8e}, }, { Name: "hash.h", Mode: 0x81a4, - Hash: core.Hash{0x82, 0xb7, 0xc5, 0x8c, 0x71, 0x9, 0xb, 0x54, 0x7e, 0x10, 0x17, 0x42, 0xaa, 0x9, 0x51, 0x73, 0x9f, 0xf2, 0xee, 0xe7}, + Hash: plumbing.Hash{0x82, 0xb7, 0xc5, 0x8c, 0x71, 0x9, 0xb, 0x54, 0x7e, 0x10, 0x17, 0x42, 0xaa, 0x9, 0x51, 0x73, 0x9f, 0xf2, 0xee, 0xe7}, }, { Name: "hwtime.h", Mode: 0x81a4, - Hash: core.Hash{0xb8, 0xbc, 0x5a, 0x29, 0x5b, 0xe3, 0xfa, 0xc8, 0x35, 0x1f, 0xa9, 0xf0, 0x8a, 0x77, 0x57, 0x9d, 0x59, 0xc9, 0xa8, 0xe4}, + Hash: plumbing.Hash{0xb8, 0xbc, 0x5a, 0x29, 0x5b, 0xe3, 0xfa, 0xc8, 0x35, 0x1f, 0xa9, 0xf0, 0x8a, 0x77, 0x57, 0x9d, 0x59, 0xc9, 0xa8, 0xe4}, }, { Name: "insert.c", Mode: 0x81a4, - Hash: core.Hash{0x9a, 0x56, 0x61, 0xf5, 0x9a, 0x72, 0x95, 0x2b, 0xe6, 0xc1, 0x67, 0xa0, 0xc2, 0xdb, 0x15, 0x9b, 0x91, 0xb7, 0x1f, 0xae}, + Hash: plumbing.Hash{0x9a, 0x56, 0x61, 0xf5, 0x9a, 0x72, 0x95, 0x2b, 0xe6, 0xc1, 0x67, 0xa0, 0xc2, 0xdb, 0x15, 0x9b, 0x91, 0xb7, 0x1f, 0xae}, }, { Name: "journal.c", Mode: 0x81a4, - Hash: core.Hash{0xfe, 0xd2, 0x7b, 0xe3, 0xe3, 0x80, 0x55, 0xd2, 0x20, 0x43, 0x95, 0xcd, 0xe6, 0xff, 0xc9, 0x45, 0x89, 0xfb, 0xf5, 0xe8}, + Hash: plumbing.Hash{0xfe, 0xd2, 0x7b, 0xe3, 0xe3, 0x80, 0x55, 0xd2, 0x20, 0x43, 0x95, 0xcd, 0xe6, 0xff, 0xc9, 0x45, 0x89, 0xfb, 0xf5, 0xe8}, }, { Name: "legacy.c", Mode: 0x81a4, - Hash: core.Hash{0x94, 0x64, 0x9a, 0xe7, 0x5, 0xab, 0x93, 0x85, 0x10, 0x8d, 0xd, 0x88, 0x7a, 0xf0, 0x75, 0x92, 0x89, 0xfb, 0x23, 0xcb}, + Hash: plumbing.Hash{0x94, 0x64, 0x9a, 0xe7, 0x5, 0xab, 0x93, 0x85, 0x10, 0x8d, 0xd, 0x88, 0x7a, 0xf0, 0x75, 0x92, 0x89, 0xfb, 0x23, 0xcb}, }, { Name: "lempar.c", Mode: 0x81a4, - Hash: core.Hash{0x2a, 0xfa, 0xa6, 0xce, 0xa6, 0xd8, 0x29, 0x60, 0x2c, 0x27, 0x86, 0xc1, 0xf8, 0xa3, 0x7f, 0x56, 0x7c, 0xf6, 0xfd, 0x53}, + Hash: plumbing.Hash{0x2a, 0xfa, 0xa6, 0xce, 0xa6, 0xd8, 0x29, 0x60, 0x2c, 0x27, 0x86, 0xc1, 0xf8, 0xa3, 0x7f, 0x56, 0x7c, 0xf6, 0xfd, 0x53}, }, { Name: "loadext.c", Mode: 0x81a4, - Hash: core.Hash{0xcd, 0xcf, 0x6a, 0x93, 0xb8, 0xc4, 0xf, 0x91, 0x4b, 0x94, 0x24, 0xe, 0xf1, 0x4c, 0xb4, 0xa3, 0xa, 0x37, 0xec, 0xa1}, + Hash: plumbing.Hash{0xcd, 0xcf, 0x6a, 0x93, 0xb8, 0xc4, 0xf, 0x91, 0x4b, 0x94, 0x24, 0xe, 0xf1, 0x4c, 0xb4, 0xa3, 0xa, 0x37, 0xec, 0xa1}, }, { Name: "main.c", Mode: 0x81a4, - Hash: core.Hash{0x39, 0xf6, 0x4, 0x21, 0xe6, 0x81, 0x27, 0x7c, 0xc3, 0xdb, 0xa0, 0x9a, 0xbe, 0x7c, 0xf7, 0x90, 0xd5, 0x28, 0xf5, 0xc3}, + Hash: plumbing.Hash{0x39, 0xf6, 0x4, 0x21, 0xe6, 0x81, 0x27, 0x7c, 0xc3, 0xdb, 0xa0, 0x9a, 0xbe, 0x7c, 0xf7, 0x90, 0xd5, 0x28, 0xf5, 0xc3}, }, { Name: "malloc.c", Mode: 0x81a4, - Hash: core.Hash{0x35, 0xa4, 0x4e, 0x5f, 0x61, 0xc2, 0xe4, 0x4c, 0x48, 0x1c, 0x62, 0x51, 0xbd, 0xa, 0xae, 0x7a, 0xcd, 0xa4, 0xde, 0xb}, + Hash: plumbing.Hash{0x35, 0xa4, 0x4e, 0x5f, 0x61, 0xc2, 0xe4, 0x4c, 0x48, 0x1c, 0x62, 0x51, 0xbd, 0xa, 0xae, 0x7a, 0xcd, 0xa4, 0xde, 0xb}, }, { Name: "mem0.c", Mode: 0x81a4, - Hash: core.Hash{0xd, 0xb, 0x66, 0x67, 0xd6, 0xa, 0x95, 0x5a, 0x6, 0x96, 0xdf, 0x62, 0x89, 0xb4, 0x91, 0x78, 0x96, 0x93, 0x43, 0xaa}, + Hash: plumbing.Hash{0xd, 0xb, 0x66, 0x67, 0xd6, 0xa, 0x95, 0x5a, 0x6, 0x96, 0xdf, 0x62, 0x89, 0xb4, 0x91, 0x78, 0x96, 0x93, 0x43, 0xaa}, }, { Name: "mem1.c", Mode: 0x81a4, - Hash: core.Hash{0x35, 0x78, 0x49, 0x6f, 0x33, 0x3, 0x7, 0xb2, 0x31, 0xdf, 0xb5, 0x3c, 0xc, 0x2e, 0x1c, 0x6b, 0x32, 0x3d, 0x79, 0x1e}, + Hash: plumbing.Hash{0x35, 0x78, 0x49, 0x6f, 0x33, 0x3, 0x7, 0xb2, 0x31, 0xdf, 0xb5, 0x3c, 0xc, 0x2e, 0x1c, 0x6b, 0x32, 0x3d, 0x79, 0x1e}, }, { Name: "mem2.c", Mode: 0x81a4, - Hash: core.Hash{0x26, 0x44, 0x8e, 0xa8, 0xaa, 0xe0, 0x36, 0x6a, 0xf0, 0x54, 0x1a, 0xfe, 0xa4, 0x79, 0xb, 0x42, 0xf4, 0xa6, 0x9b, 0x5a}, + Hash: plumbing.Hash{0x26, 0x44, 0x8e, 0xa8, 0xaa, 0xe0, 0x36, 0x6a, 0xf0, 0x54, 0x1a, 0xfe, 0xa4, 0x79, 0xb, 0x42, 0xf4, 0xa6, 0x9b, 0x5a}, }, { Name: "mem3.c", Mode: 0x81a4, - Hash: core.Hash{0x1a, 0x1b, 0x79, 0x1f, 0x28, 0xf8, 0xcf, 0x3c, 0xe4, 0xf9, 0xa3, 0x5c, 0xda, 0xd7, 0xb7, 0x10, 0x75, 0x68, 0xc7, 0x15}, + Hash: plumbing.Hash{0x1a, 0x1b, 0x79, 0x1f, 0x28, 0xf8, 0xcf, 0x3c, 0xe4, 0xf9, 0xa3, 0x5c, 0xda, 0xd7, 0xb7, 0x10, 0x75, 0x68, 0xc7, 0x15}, }, { Name: "mem5.c", Mode: 0x81a4, - Hash: core.Hash{0x78, 0x3c, 0xef, 0x61, 0x76, 0xc5, 0x9c, 0xbf, 0x30, 0x91, 0x46, 0x31, 0x9, 0x5a, 0x1a, 0x54, 0xf4, 0xe4, 0x2e, 0x8}, + Hash: plumbing.Hash{0x78, 0x3c, 0xef, 0x61, 0x76, 0xc5, 0x9c, 0xbf, 0x30, 0x91, 0x46, 0x31, 0x9, 0x5a, 0x1a, 0x54, 0xf4, 0xe4, 0x2e, 0x8}, }, { Name: "memjournal.c", Mode: 0x81a4, - Hash: core.Hash{0x5, 0x72, 0x59, 0x48, 0xf6, 0x5d, 0x42, 0x7b, 0x7, 0xf7, 0xf9, 0x29, 0xac, 0xa3, 0xff, 0x22, 0x4b, 0x17, 0x53, 0xdf}, + Hash: plumbing.Hash{0x5, 0x72, 0x59, 0x48, 0xf6, 0x5d, 0x42, 0x7b, 0x7, 0xf7, 0xf9, 0x29, 0xac, 0xa3, 0xff, 0x22, 0x4b, 0x17, 0x53, 0xdf}, }, { Name: "mutex.c", Mode: 0x81a4, - Hash: core.Hash{0xb5, 0x67, 0xe7, 0xc2, 0x7e, 0xf2, 0x4, 0x10, 0x86, 0xaf, 0xe0, 0xf6, 0x96, 0x66, 0xe2, 0x7b, 0xf5, 0x9, 0x8a, 0x59}, + Hash: plumbing.Hash{0xb5, 0x67, 0xe7, 0xc2, 0x7e, 0xf2, 0x4, 0x10, 0x86, 0xaf, 0xe0, 0xf6, 0x96, 0x66, 0xe2, 0x7b, 0xf5, 0x9, 0x8a, 0x59}, }, { Name: "mutex.h", Mode: 0x81a4, - Hash: core.Hash{0x9, 0x78, 0x81, 0x22, 0x52, 0x77, 0x89, 0xa, 0x9c, 0x36, 0xc2, 0x4d, 0x41, 0xf6, 0x11, 0x4d, 0x64, 0xc0, 0x6d, 0xb3}, + Hash: plumbing.Hash{0x9, 0x78, 0x81, 0x22, 0x52, 0x77, 0x89, 0xa, 0x9c, 0x36, 0xc2, 0x4d, 0x41, 0xf6, 0x11, 0x4d, 0x64, 0xc0, 0x6d, 0xb3}, }, { Name: "mutex_noop.c", Mode: 0x81a4, - Hash: core.Hash{0x45, 0x6e, 0x82, 0xa2, 0x5e, 0x27, 0x1b, 0x6, 0x14, 0xe7, 0xf4, 0xf8, 0x3c, 0x22, 0x85, 0x53, 0xb7, 0xfa, 0x1, 0x58}, + Hash: plumbing.Hash{0x45, 0x6e, 0x82, 0xa2, 0x5e, 0x27, 0x1b, 0x6, 0x14, 0xe7, 0xf4, 0xf8, 0x3c, 0x22, 0x85, 0x53, 0xb7, 0xfa, 0x1, 0x58}, }, { Name: "mutex_unix.c", Mode: 0x81a4, - Hash: core.Hash{0xec, 0xa7, 0x29, 0x58, 0x31, 0xc2, 0xf0, 0xee, 0x48, 0xba, 0x54, 0xd0, 0x62, 0x91, 0x4d, 0x6, 0xa1, 0xdd, 0x8e, 0xbe}, + Hash: plumbing.Hash{0xec, 0xa7, 0x29, 0x58, 0x31, 0xc2, 0xf0, 0xee, 0x48, 0xba, 0x54, 0xd0, 0x62, 0x91, 0x4d, 0x6, 0xa1, 0xdd, 0x8e, 0xbe}, }, { Name: "mutex_w32.c", Mode: 0x81a4, - Hash: core.Hash{0x27, 0xd1, 0xa, 0xf5, 0xbd, 0x33, 0x1b, 0xdb, 0x97, 0x3f, 0x61, 0x45, 0xb7, 0x4f, 0x72, 0xb6, 0x7, 0xcf, 0xc4, 0x6e}, + Hash: plumbing.Hash{0x27, 0xd1, 0xa, 0xf5, 0xbd, 0x33, 0x1b, 0xdb, 0x97, 0x3f, 0x61, 0x45, 0xb7, 0x4f, 0x72, 0xb6, 0x7, 0xcf, 0xc4, 0x6e}, }, { Name: "notify.c", Mode: 0x81a4, - Hash: core.Hash{0xfc, 0xab, 0x5b, 0xfa, 0xf0, 0x19, 0x8, 0xd3, 0xde, 0x93, 0xfa, 0x88, 0xb5, 0xea, 0xe9, 0xe9, 0x6c, 0xa3, 0xc8, 0xe8}, + Hash: plumbing.Hash{0xfc, 0xab, 0x5b, 0xfa, 0xf0, 0x19, 0x8, 0xd3, 0xde, 0x93, 0xfa, 0x88, 0xb5, 0xea, 0xe9, 0xe9, 0x6c, 0xa3, 0xc8, 0xe8}, }, { Name: "os.c", Mode: 0x81a4, - Hash: core.Hash{0xbe, 0x2e, 0xa4, 0xcf, 0xc0, 0x19, 0x59, 0x93, 0xa3, 0x40, 0xc9, 0x2, 0xae, 0xdd, 0xf1, 0xbe, 0x4b, 0x8e, 0xd7, 0x3a}, + Hash: plumbing.Hash{0xbe, 0x2e, 0xa4, 0xcf, 0xc0, 0x19, 0x59, 0x93, 0xa3, 0x40, 0xc9, 0x2, 0xae, 0xdd, 0xf1, 0xbe, 0x4b, 0x8e, 0xd7, 0x3a}, }, { Name: "os.h", Mode: 0x81a4, - Hash: core.Hash{0x7, 0xa, 0x2d, 0xdd, 0x17, 0xf7, 0x71, 0xf9, 0x8f, 0xf8, 0xcc, 0xd6, 0xf0, 0x33, 0xbd, 0xac, 0xc5, 0xe9, 0xf6, 0xc}, + Hash: plumbing.Hash{0x7, 0xa, 0x2d, 0xdd, 0x17, 0xf7, 0x71, 0xf9, 0x8f, 0xf8, 0xcc, 0xd6, 0xf0, 0x33, 0xbd, 0xac, 0xc5, 0xe9, 0xf6, 0xc}, }, { Name: "os_common.h", Mode: 0x81a4, - Hash: core.Hash{0xf6, 0xc3, 0xe7, 0xff, 0x89, 0x46, 0x30, 0x86, 0x40, 0x18, 0x22, 0xf4, 0x81, 0xe7, 0xe3, 0xb8, 0x7b, 0x2c, 0x78, 0xc7}, + Hash: plumbing.Hash{0xf6, 0xc3, 0xe7, 0xff, 0x89, 0x46, 0x30, 0x86, 0x40, 0x18, 0x22, 0xf4, 0x81, 0xe7, 0xe3, 0xb8, 0x7b, 0x2c, 0x78, 0xc7}, }, { Name: "os_unix.c", Mode: 0x81a4, - Hash: core.Hash{0xab, 0xc2, 0x3a, 0x45, 0x2e, 0x72, 0xf7, 0x1c, 0x76, 0xaf, 0xa9, 0x98, 0x3c, 0x3a, 0xd9, 0xd4, 0x25, 0x61, 0x6c, 0x6d}, + Hash: plumbing.Hash{0xab, 0xc2, 0x3a, 0x45, 0x2e, 0x72, 0xf7, 0x1c, 0x76, 0xaf, 0xa9, 0x98, 0x3c, 0x3a, 0xd9, 0xd4, 0x25, 0x61, 0x6c, 0x6d}, }, { Name: "os_win.c", Mode: 0x81a4, - Hash: core.Hash{0xae, 0xb0, 0x88, 0x14, 0xb3, 0xda, 0xbe, 0x81, 0xb8, 0x4c, 0xda, 0x91, 0x85, 0x82, 0xb0, 0xf, 0xfd, 0x86, 0xe4, 0x87}, + Hash: plumbing.Hash{0xae, 0xb0, 0x88, 0x14, 0xb3, 0xda, 0xbe, 0x81, 0xb8, 0x4c, 0xda, 0x91, 0x85, 0x82, 0xb0, 0xf, 0xfd, 0x86, 0xe4, 0x87}, }, { Name: "pager.c", Mode: 0x81a4, - Hash: core.Hash{0x61, 0x72, 0x7f, 0xaa, 0x9c, 0xf, 0x3d, 0x56, 0x62, 0x65, 0xbe, 0x7e, 0xec, 0x5b, 0x2a, 0x35, 0xf6, 0xa4, 0xbc, 0x9f}, + Hash: plumbing.Hash{0x61, 0x72, 0x7f, 0xaa, 0x9c, 0xf, 0x3d, 0x56, 0x62, 0x65, 0xbe, 0x7e, 0xec, 0x5b, 0x2a, 0x35, 0xf6, 0xa4, 0xbc, 0x9f}, }, { Name: "pager.h", Mode: 0x81a4, - Hash: core.Hash{0x6f, 0x65, 0x91, 0x36, 0xe2, 0x76, 0x7, 0x9d, 0xa4, 0x3a, 0x2e, 0x39, 0xe1, 0xb6, 0x86, 0x37, 0xec, 0xad, 0xcf, 0x68}, + Hash: plumbing.Hash{0x6f, 0x65, 0x91, 0x36, 0xe2, 0x76, 0x7, 0x9d, 0xa4, 0x3a, 0x2e, 0x39, 0xe1, 0xb6, 0x86, 0x37, 0xec, 0xad, 0xcf, 0x68}, }, { Name: "parse.y", Mode: 0x81a4, - Hash: core.Hash{0x83, 0x10, 0xb2, 0x69, 0x89, 0xb0, 0x5b, 0xed, 0x1e, 0x1b, 0x3, 0xda, 0x80, 0xf5, 0xc0, 0xa5, 0x2e, 0x9a, 0xd1, 0xd2}, + Hash: plumbing.Hash{0x83, 0x10, 0xb2, 0x69, 0x89, 0xb0, 0x5b, 0xed, 0x1e, 0x1b, 0x3, 0xda, 0x80, 0xf5, 0xc0, 0xa5, 0x2e, 0x9a, 0xd1, 0xd2}, }, { Name: "pcache.c", Mode: 0x81a4, - Hash: core.Hash{0x48, 0x2a, 0x18, 0x8b, 0xee, 0x19, 0x91, 0xbc, 0x8a, 0xda, 0xc9, 0x6a, 0x19, 0x3a, 0x53, 0xe5, 0x46, 0x2a, 0x8c, 0x10}, + Hash: plumbing.Hash{0x48, 0x2a, 0x18, 0x8b, 0xee, 0x19, 0x91, 0xbc, 0x8a, 0xda, 0xc9, 0x6a, 0x19, 0x3a, 0x53, 0xe5, 0x46, 0x2a, 0x8c, 0x10}, }, { Name: "pcache.h", Mode: 0x81a4, - Hash: core.Hash{0xf4, 0xd4, 0xad, 0x71, 0xc1, 0xd, 0x78, 0xc6, 0xda, 0xbd, 0xe2, 0x52, 0x15, 0xcd, 0x41, 0x5a, 0x76, 0x1, 0x48, 0xca}, + Hash: plumbing.Hash{0xf4, 0xd4, 0xad, 0x71, 0xc1, 0xd, 0x78, 0xc6, 0xda, 0xbd, 0xe2, 0x52, 0x15, 0xcd, 0x41, 0x5a, 0x76, 0x1, 0x48, 0xca}, }, { Name: "pcache1.c", Mode: 0x81a4, - Hash: core.Hash{0x41, 0x47, 0xd2, 0xef, 0xf5, 0x5b, 0xdd, 0x9f, 0xf7, 0xc6, 0x86, 0xc, 0x60, 0x18, 0x10, 0x20, 0x16, 0x6c, 0x5f, 0x50}, + Hash: plumbing.Hash{0x41, 0x47, 0xd2, 0xef, 0xf5, 0x5b, 0xdd, 0x9f, 0xf7, 0xc6, 0x86, 0xc, 0x60, 0x18, 0x10, 0x20, 0x16, 0x6c, 0x5f, 0x50}, }, { Name: "pragma.c", Mode: 0x81a4, - Hash: core.Hash{0x22, 0x97, 0x71, 0x69, 0x61, 0x7d, 0x49, 0x22, 0xb3, 0x99, 0x3f, 0x76, 0x9d, 0x90, 0xfa, 0x7b, 0xc4, 0x41, 0xea, 0x50}, + Hash: plumbing.Hash{0x22, 0x97, 0x71, 0x69, 0x61, 0x7d, 0x49, 0x22, 0xb3, 0x99, 0x3f, 0x76, 0x9d, 0x90, 0xfa, 0x7b, 0xc4, 0x41, 0xea, 0x50}, }, { Name: "prepare.c", Mode: 0x81a4, - Hash: core.Hash{0xd7, 0x8d, 0x83, 0xcb, 0xd8, 0x78, 0x97, 0xf5, 0x73, 0x30, 0x3f, 0x9f, 0x57, 0xab, 0x8d, 0xe0, 0x24, 0xa6, 0xe3, 0xf8}, + Hash: plumbing.Hash{0xd7, 0x8d, 0x83, 0xcb, 0xd8, 0x78, 0x97, 0xf5, 0x73, 0x30, 0x3f, 0x9f, 0x57, 0xab, 0x8d, 0xe0, 0x24, 0xa6, 0xe3, 0xf8}, }, { Name: "printf.c", Mode: 0x81a4, - Hash: core.Hash{0x9f, 0x68, 0xd2, 0x4, 0xff, 0xdc, 0x9f, 0x3d, 0x42, 0x7f, 0x80, 0xa8, 0x23, 0x9a, 0x7f, 0xa3, 0xa9, 0x8a, 0xec, 0xbd}, + Hash: plumbing.Hash{0x9f, 0x68, 0xd2, 0x4, 0xff, 0xdc, 0x9f, 0x3d, 0x42, 0x7f, 0x80, 0xa8, 0x23, 0x9a, 0x7f, 0xa3, 0xa9, 0x8a, 0xec, 0xbd}, }, { Name: "random.c", Mode: 0x81a4, - Hash: core.Hash{0x23, 0x4e, 0xbd, 0xf6, 0x58, 0xf4, 0x36, 0xcc, 0x7c, 0x68, 0xf0, 0x27, 0xc4, 0x8b, 0xe, 0x1b, 0x9b, 0xa3, 0x4e, 0x98}, + Hash: plumbing.Hash{0x23, 0x4e, 0xbd, 0xf6, 0x58, 0xf4, 0x36, 0xcc, 0x7c, 0x68, 0xf0, 0x27, 0xc4, 0x8b, 0xe, 0x1b, 0x9b, 0xa3, 0x4e, 0x98}, }, { Name: "resolve.c", Mode: 0x81a4, - Hash: core.Hash{0x91, 0xef, 0xca, 0xa1, 0xa1, 0x6b, 0xfc, 0x98, 0xfb, 0x35, 0xd8, 0x5c, 0xad, 0x15, 0x6b, 0x93, 0x53, 0x3e, 0x4e, 0x6}, + Hash: plumbing.Hash{0x91, 0xef, 0xca, 0xa1, 0xa1, 0x6b, 0xfc, 0x98, 0xfb, 0x35, 0xd8, 0x5c, 0xad, 0x15, 0x6b, 0x93, 0x53, 0x3e, 0x4e, 0x6}, }, { Name: "rowset.c", Mode: 0x81a4, - Hash: core.Hash{0x57, 0x61, 0xf9, 0x85, 0x50, 0xb1, 0x76, 0xcc, 0xe1, 0x1d, 0xcb, 0xce, 0xc9, 0x38, 0x99, 0xa0, 0x75, 0xbb, 0x64, 0xfd}, + Hash: plumbing.Hash{0x57, 0x61, 0xf9, 0x85, 0x50, 0xb1, 0x76, 0xcc, 0xe1, 0x1d, 0xcb, 0xce, 0xc9, 0x38, 0x99, 0xa0, 0x75, 0xbb, 0x64, 0xfd}, }, { Name: "select.c", Mode: 0x81a4, - Hash: core.Hash{0xf3, 0xf1, 0x49, 0x9, 0x63, 0x95, 0x5b, 0x8e, 0xd0, 0xc9, 0xfe, 0x6e, 0x1e, 0xec, 0x83, 0x6c, 0x1a, 0x52, 0x94, 0xb4}, + Hash: plumbing.Hash{0xf3, 0xf1, 0x49, 0x9, 0x63, 0x95, 0x5b, 0x8e, 0xd0, 0xc9, 0xfe, 0x6e, 0x1e, 0xec, 0x83, 0x6c, 0x1a, 0x52, 0x94, 0xb4}, }, { Name: "shell.c", Mode: 0x81a4, - Hash: core.Hash{0x1b, 0xe2, 0x87, 0x1f, 0xed, 0x9a, 0x1f, 0xdf, 0x1d, 0xf7, 0x19, 0x8e, 0x11, 0x25, 0x36, 0x0, 0xec, 0xba, 0x76, 0xcc}, + Hash: plumbing.Hash{0x1b, 0xe2, 0x87, 0x1f, 0xed, 0x9a, 0x1f, 0xdf, 0x1d, 0xf7, 0x19, 0x8e, 0x11, 0x25, 0x36, 0x0, 0xec, 0xba, 0x76, 0xcc}, }, { Name: "sqlcipher.h", Mode: 0x81a4, - Hash: core.Hash{0x82, 0x75, 0x30, 0x95, 0xcd, 0x17, 0x23, 0xc5, 0xff, 0x4f, 0x11, 0x15, 0xe4, 0x97, 0x55, 0x91, 0xee, 0x34, 0xf5, 0xce}, + Hash: plumbing.Hash{0x82, 0x75, 0x30, 0x95, 0xcd, 0x17, 0x23, 0xc5, 0xff, 0x4f, 0x11, 0x15, 0xe4, 0x97, 0x55, 0x91, 0xee, 0x34, 0xf5, 0xce}, }, { Name: "sqlite.h.in", Mode: 0x81a4, - Hash: core.Hash{0x66, 0x8, 0x82, 0x31, 0x75, 0xde, 0x5b, 0x6a, 0xd, 0x37, 0x8f, 0xdb, 0xc, 0x38, 0x18, 0xb6, 0xab, 0x4f, 0xbf, 0x8e}, + Hash: plumbing.Hash{0x66, 0x8, 0x82, 0x31, 0x75, 0xde, 0x5b, 0x6a, 0xd, 0x37, 0x8f, 0xdb, 0xc, 0x38, 0x18, 0xb6, 0xab, 0x4f, 0xbf, 0x8e}, }, { Name: "sqlite3.rc", Mode: 0x81a4, - Hash: core.Hash{0x96, 0x98, 0x76, 0xda, 0x1e, 0x57, 0x14, 0x3d, 0xe0, 0xb4, 0xd1, 0xc7, 0x62, 0x9f, 0xd3, 0x35, 0x6f, 0x2e, 0x1c, 0x96}, + Hash: plumbing.Hash{0x96, 0x98, 0x76, 0xda, 0x1e, 0x57, 0x14, 0x3d, 0xe0, 0xb4, 0xd1, 0xc7, 0x62, 0x9f, 0xd3, 0x35, 0x6f, 0x2e, 0x1c, 0x96}, }, { Name: "sqlite3ext.h", Mode: 0x81a4, - Hash: core.Hash{0x92, 0x8b, 0xb3, 0xba, 0xd9, 0xdd, 0x64, 0x3c, 0x30, 0x1d, 0xd2, 0xb0, 0xac, 0x22, 0x28, 0x7a, 0x81, 0x28, 0x48, 0x84}, + Hash: plumbing.Hash{0x92, 0x8b, 0xb3, 0xba, 0xd9, 0xdd, 0x64, 0x3c, 0x30, 0x1d, 0xd2, 0xb0, 0xac, 0x22, 0x28, 0x7a, 0x81, 0x28, 0x48, 0x84}, }, { Name: "sqliteInt.h", Mode: 0x81a4, - Hash: core.Hash{0x59, 0x50, 0xf2, 0x37, 0xd9, 0xf9, 0xf2, 0xd3, 0xef, 0x6b, 0xd8, 0xbe, 0x34, 0x2d, 0xcf, 0x64, 0x89, 0x22, 0x51, 0x42}, + Hash: plumbing.Hash{0x59, 0x50, 0xf2, 0x37, 0xd9, 0xf9, 0xf2, 0xd3, 0xef, 0x6b, 0xd8, 0xbe, 0x34, 0x2d, 0xcf, 0x64, 0x89, 0x22, 0x51, 0x42}, }, { Name: "sqliteLimit.h", Mode: 0x81a4, - Hash: core.Hash{0xc7, 0xae, 0xe5, 0x3c, 0xeb, 0xca, 0x94, 0xda, 0x51, 0xe7, 0x1a, 0x82, 0x2e, 0xa5, 0xa6, 0xde, 0xb9, 0x3, 0x85, 0xdf}, + Hash: plumbing.Hash{0xc7, 0xae, 0xe5, 0x3c, 0xeb, 0xca, 0x94, 0xda, 0x51, 0xe7, 0x1a, 0x82, 0x2e, 0xa5, 0xa6, 0xde, 0xb9, 0x3, 0x85, 0xdf}, }, { Name: "status.c", Mode: 0x81a4, - Hash: core.Hash{0x28, 0x34, 0x9e, 0x6d, 0x3d, 0x20, 0x88, 0xe0, 0x0, 0x3b, 0x76, 0xf8, 0xa, 0x89, 0x54, 0xfa, 0xec, 0x59, 0x30, 0xba}, + Hash: plumbing.Hash{0x28, 0x34, 0x9e, 0x6d, 0x3d, 0x20, 0x88, 0xe0, 0x0, 0x3b, 0x76, 0xf8, 0xa, 0x89, 0x54, 0xfa, 0xec, 0x59, 0x30, 0xba}, }, { Name: "table.c", Mode: 0x81a4, - Hash: core.Hash{0x26, 0xbb, 0xfb, 0x4f, 0x45, 0x6c, 0x42, 0x98, 0x25, 0x29, 0xea, 0x1a, 0x63, 0xa0, 0x17, 0x51, 0xdd, 0x3e, 0xe9, 0x5a}, + Hash: plumbing.Hash{0x26, 0xbb, 0xfb, 0x4f, 0x45, 0x6c, 0x42, 0x98, 0x25, 0x29, 0xea, 0x1a, 0x63, 0xa0, 0x17, 0x51, 0xdd, 0x3e, 0xe9, 0x5a}, }, { Name: "tclsqlite.c", Mode: 0x81a4, - Hash: core.Hash{0xf1, 0xbb, 0x29, 0x21, 0xda, 0xc, 0x68, 0xa4, 0xf1, 0xc8, 0xe1, 0x5c, 0xf5, 0x66, 0xb2, 0x33, 0xe9, 0x2a, 0x51, 0x9f}, + Hash: plumbing.Hash{0xf1, 0xbb, 0x29, 0x21, 0xda, 0xc, 0x68, 0xa4, 0xf1, 0xc8, 0xe1, 0x5c, 0xf5, 0x66, 0xb2, 0x33, 0xe9, 0x2a, 0x51, 0x9f}, }, { Name: "test1.c", Mode: 0x81a4, - Hash: core.Hash{0xa6, 0x38, 0xe4, 0x80, 0xad, 0xdf, 0x14, 0x43, 0x9c, 0xdf, 0xa4, 0xee, 0x16, 0x4d, 0xc3, 0x1b, 0x79, 0xf8, 0xbc, 0xac}, + Hash: plumbing.Hash{0xa6, 0x38, 0xe4, 0x80, 0xad, 0xdf, 0x14, 0x43, 0x9c, 0xdf, 0xa4, 0xee, 0x16, 0x4d, 0xc3, 0x1b, 0x79, 0xf8, 0xbc, 0xac}, }, { Name: "test2.c", Mode: 0x81a4, - Hash: core.Hash{0xd1, 0x30, 0xe9, 0xd0, 0x1b, 0x70, 0x24, 0xa5, 0xec, 0x6d, 0x73, 0x5, 0x92, 0xee, 0x4d, 0x1f, 0xb0, 0x2c, 0xfd, 0xb4}, + Hash: plumbing.Hash{0xd1, 0x30, 0xe9, 0xd0, 0x1b, 0x70, 0x24, 0xa5, 0xec, 0x6d, 0x73, 0x5, 0x92, 0xee, 0x4d, 0x1f, 0xb0, 0x2c, 0xfd, 0xb4}, }, { Name: "test3.c", Mode: 0x81a4, - Hash: core.Hash{0xe3, 0xed, 0x31, 0xc, 0x81, 0x4, 0xfe, 0x36, 0x21, 0xce, 0xbb, 0xf, 0x51, 0xd1, 0x1, 0x45, 0x1, 0x8d, 0x4f, 0xac}, + Hash: plumbing.Hash{0xe3, 0xed, 0x31, 0xc, 0x81, 0x4, 0xfe, 0x36, 0x21, 0xce, 0xbb, 0xf, 0x51, 0xd1, 0x1, 0x45, 0x1, 0x8d, 0x4f, 0xac}, }, { Name: "test4.c", Mode: 0x81a4, - Hash: core.Hash{0xa6, 0x37, 0x5c, 0x7c, 0xc4, 0x3, 0xf6, 0xc, 0xaa, 0xb7, 0xe9, 0x59, 0x53, 0x3e, 0x3d, 0xb1, 0xff, 0x75, 0xa, 0xe4}, + Hash: plumbing.Hash{0xa6, 0x37, 0x5c, 0x7c, 0xc4, 0x3, 0xf6, 0xc, 0xaa, 0xb7, 0xe9, 0x59, 0x53, 0x3e, 0x3d, 0xb1, 0xff, 0x75, 0xa, 0xe4}, }, { Name: "test5.c", Mode: 0x81a4, - Hash: core.Hash{0x30, 0x3d, 0x12, 0x5, 0xb2, 0x26, 0x28, 0x42, 0x3d, 0x98, 0x6f, 0x71, 0xe2, 0x7c, 0x7c, 0xf7, 0x14, 0xa7, 0x45, 0xa6}, + Hash: plumbing.Hash{0x30, 0x3d, 0x12, 0x5, 0xb2, 0x26, 0x28, 0x42, 0x3d, 0x98, 0x6f, 0x71, 0xe2, 0x7c, 0x7c, 0xf7, 0x14, 0xa7, 0x45, 0xa6}, }, { Name: "test6.c", Mode: 0x81a4, - Hash: core.Hash{0xc1, 0x51, 0xea, 0x42, 0x98, 0x9b, 0xb, 0xe2, 0x4e, 0xe4, 0xb9, 0xa4, 0xbe, 0x37, 0x8b, 0x4f, 0x63, 0x6d, 0xb6, 0x41}, + Hash: plumbing.Hash{0xc1, 0x51, 0xea, 0x42, 0x98, 0x9b, 0xb, 0xe2, 0x4e, 0xe4, 0xb9, 0xa4, 0xbe, 0x37, 0x8b, 0x4f, 0x63, 0x6d, 0xb6, 0x41}, }, { Name: "test7.c", Mode: 0x81a4, - Hash: core.Hash{0x3c, 0xd4, 0xa2, 0x24, 0xd7, 0xe8, 0xe1, 0x6b, 0xd7, 0xcb, 0xe4, 0x9e, 0x2d, 0x3e, 0x94, 0xce, 0x9b, 0x17, 0xbd, 0x76}, + Hash: plumbing.Hash{0x3c, 0xd4, 0xa2, 0x24, 0xd7, 0xe8, 0xe1, 0x6b, 0xd7, 0xcb, 0xe4, 0x9e, 0x2d, 0x3e, 0x94, 0xce, 0x9b, 0x17, 0xbd, 0x76}, }, { Name: "test8.c", Mode: 0x81a4, - Hash: core.Hash{0xc5, 0x73, 0x93, 0x32, 0xd4, 0x6e, 0x57, 0x12, 0x1d, 0xa2, 0x7c, 0x3e, 0x88, 0xfd, 0xe7, 0x5a, 0xeb, 0x87, 0x10, 0xf7}, + Hash: plumbing.Hash{0xc5, 0x73, 0x93, 0x32, 0xd4, 0x6e, 0x57, 0x12, 0x1d, 0xa2, 0x7c, 0x3e, 0x88, 0xfd, 0xe7, 0x5a, 0xeb, 0x87, 0x10, 0xf7}, }, { Name: "test9.c", Mode: 0x81a4, - Hash: core.Hash{0xe5, 0x99, 0x3e, 0x8f, 0xf7, 0x8f, 0x61, 0xc2, 0x43, 0x5b, 0x6f, 0x97, 0xa3, 0xb4, 0x63, 0xe2, 0x27, 0xc7, 0x67, 0xac}, + Hash: plumbing.Hash{0xe5, 0x99, 0x3e, 0x8f, 0xf7, 0x8f, 0x61, 0xc2, 0x43, 0x5b, 0x6f, 0x97, 0xa3, 0xb4, 0x63, 0xe2, 0x27, 0xc7, 0x67, 0xac}, }, { Name: "test_async.c", Mode: 0x81a4, - Hash: core.Hash{0xb0, 0xb9, 0x43, 0x18, 0x5b, 0xfc, 0x23, 0xc1, 0x7f, 0xd0, 0x8f, 0x55, 0x76, 0x8c, 0xac, 0x12, 0xa9, 0xf5, 0x69, 0x51}, + Hash: plumbing.Hash{0xb0, 0xb9, 0x43, 0x18, 0x5b, 0xfc, 0x23, 0xc1, 0x7f, 0xd0, 0x8f, 0x55, 0x76, 0x8c, 0xac, 0x12, 0xa9, 0xf5, 0x69, 0x51}, }, { Name: "test_autoext.c", Mode: 0x81a4, - Hash: core.Hash{0xb5, 0x1, 0x3f, 0x31, 0x73, 0xa2, 0x17, 0x6e, 0x2d, 0x9f, 0xc, 0xaa, 0x99, 0x19, 0x30, 0x36, 0xbf, 0xc3, 0x7e, 0x91}, + Hash: plumbing.Hash{0xb5, 0x1, 0x3f, 0x31, 0x73, 0xa2, 0x17, 0x6e, 0x2d, 0x9f, 0xc, 0xaa, 0x99, 0x19, 0x30, 0x36, 0xbf, 0xc3, 0x7e, 0x91}, }, { Name: "test_backup.c", Mode: 0x81a4, - Hash: core.Hash{0xe9, 0x67, 0x42, 0x4a, 0x29, 0xf, 0x73, 0x8a, 0xec, 0xfd, 0xac, 0x57, 0x8e, 0x9b, 0x87, 0xa4, 0xc4, 0xae, 0x8d, 0x7f}, + Hash: plumbing.Hash{0xe9, 0x67, 0x42, 0x4a, 0x29, 0xf, 0x73, 0x8a, 0xec, 0xfd, 0xac, 0x57, 0x8e, 0x9b, 0x87, 0xa4, 0xc4, 0xae, 0x8d, 0x7f}, }, { Name: "test_btree.c", Mode: 0x81a4, - Hash: core.Hash{0xdb, 0x72, 0x88, 0x9b, 0x2a, 0xfb, 0x62, 0x72, 0x82, 0x8d, 0xda, 0x86, 0x6d, 0xcc, 0xf1, 0x22, 0xa4, 0x9a, 0x72, 0x99}, + Hash: plumbing.Hash{0xdb, 0x72, 0x88, 0x9b, 0x2a, 0xfb, 0x62, 0x72, 0x82, 0x8d, 0xda, 0x86, 0x6d, 0xcc, 0xf1, 0x22, 0xa4, 0x9a, 0x72, 0x99}, }, { Name: "test_config.c", Mode: 0x81a4, - Hash: core.Hash{0x53, 0x47, 0x27, 0xa0, 0x80, 0x42, 0xb6, 0xca, 0xd6, 0x7e, 0x26, 0x7e, 0x87, 0xb4, 0x3, 0xa4, 0x1a, 0x73, 0xb2, 0x99}, + Hash: plumbing.Hash{0x53, 0x47, 0x27, 0xa0, 0x80, 0x42, 0xb6, 0xca, 0xd6, 0x7e, 0x26, 0x7e, 0x87, 0xb4, 0x3, 0xa4, 0x1a, 0x73, 0xb2, 0x99}, }, { Name: "test_demovfs.c", Mode: 0x81a4, - Hash: core.Hash{0x63, 0x76, 0x27, 0x7, 0x1d, 0x9e, 0x28, 0xf4, 0xb3, 0x45, 0x1b, 0xbb, 0xdd, 0xf8, 0x8, 0xd1, 0xa9, 0x12, 0x0, 0xf8}, + Hash: plumbing.Hash{0x63, 0x76, 0x27, 0x7, 0x1d, 0x9e, 0x28, 0xf4, 0xb3, 0x45, 0x1b, 0xbb, 0xdd, 0xf8, 0x8, 0xd1, 0xa9, 0x12, 0x0, 0xf8}, }, { Name: "test_devsym.c", Mode: 0x81a4, - Hash: core.Hash{0x21, 0xf0, 0xf6, 0x84, 0xd8, 0x61, 0x11, 0x67, 0x70, 0xde, 0xfc, 0xde, 0xcd, 0x53, 0x2b, 0xa3, 0xee, 0xab, 0xa9, 0x75}, + Hash: plumbing.Hash{0x21, 0xf0, 0xf6, 0x84, 0xd8, 0x61, 0x11, 0x67, 0x70, 0xde, 0xfc, 0xde, 0xcd, 0x53, 0x2b, 0xa3, 0xee, 0xab, 0xa9, 0x75}, }, { Name: "test_fs.c", Mode: 0x81a4, - Hash: core.Hash{0x47, 0x8c, 0xad, 0x80, 0xb1, 0x6a, 0x90, 0x9b, 0x23, 0xbd, 0x3, 0xc2, 0xda, 0xd8, 0xb4, 0x49, 0xa7, 0x45, 0x87, 0xa1}, + Hash: plumbing.Hash{0x47, 0x8c, 0xad, 0x80, 0xb1, 0x6a, 0x90, 0x9b, 0x23, 0xbd, 0x3, 0xc2, 0xda, 0xd8, 0xb4, 0x49, 0xa7, 0x45, 0x87, 0xa1}, }, { Name: "test_func.c", Mode: 0x81a4, - Hash: core.Hash{0x6f, 0x9b, 0xb0, 0x3d, 0xc8, 0x8a, 0x21, 0xd6, 0x58, 0xbf, 0x99, 0x99, 0xba, 0xf6, 0x6d, 0xc1, 0xd5, 0x2e, 0xbc, 0x54}, + Hash: plumbing.Hash{0x6f, 0x9b, 0xb0, 0x3d, 0xc8, 0x8a, 0x21, 0xd6, 0x58, 0xbf, 0x99, 0x99, 0xba, 0xf6, 0x6d, 0xc1, 0xd5, 0x2e, 0xbc, 0x54}, }, { Name: "test_hexio.c", Mode: 0x81a4, - Hash: core.Hash{0xb2, 0xb, 0x5c, 0xe7, 0x30, 0xab, 0x7f, 0xa8, 0x0, 0xd2, 0xd0, 0xcc, 0x38, 0xc7, 0x72, 0x75, 0x59, 0x3e, 0xbd, 0xbb}, + Hash: plumbing.Hash{0xb2, 0xb, 0x5c, 0xe7, 0x30, 0xab, 0x7f, 0xa8, 0x0, 0xd2, 0xd0, 0xcc, 0x38, 0xc7, 0x72, 0x75, 0x59, 0x3e, 0xbd, 0xbb}, }, { Name: "test_init.c", Mode: 0x81a4, - Hash: core.Hash{0xe3, 0x72, 0x4d, 0x8b, 0xe3, 0x14, 0xdb, 0x9, 0xee, 0xa8, 0x4, 0xb, 0x9d, 0xdf, 0xc8, 0xa8, 0xbe, 0xee, 0x22, 0x91}, + Hash: plumbing.Hash{0xe3, 0x72, 0x4d, 0x8b, 0xe3, 0x14, 0xdb, 0x9, 0xee, 0xa8, 0x4, 0xb, 0x9d, 0xdf, 0xc8, 0xa8, 0xbe, 0xee, 0x22, 0x91}, }, { Name: "test_intarray.c", Mode: 0x81a4, - Hash: core.Hash{0xf5, 0xc3, 0xd9, 0xe4, 0x5, 0x9a, 0x16, 0x56, 0x7, 0x34, 0x7, 0xe4, 0x3a, 0x92, 0x11, 0x79, 0x99, 0x69, 0x7b, 0x93}, + Hash: plumbing.Hash{0xf5, 0xc3, 0xd9, 0xe4, 0x5, 0x9a, 0x16, 0x56, 0x7, 0x34, 0x7, 0xe4, 0x3a, 0x92, 0x11, 0x79, 0x99, 0x69, 0x7b, 0x93}, }, { Name: "test_intarray.h", Mode: 0x81a4, - Hash: core.Hash{0x69, 0x13, 0x37, 0xd1, 0xae, 0xd6, 0x37, 0x15, 0xd6, 0x2e, 0x76, 0x26, 0x6f, 0xf, 0x3b, 0x50, 0x8b, 0x1, 0xa, 0x34}, + Hash: plumbing.Hash{0x69, 0x13, 0x37, 0xd1, 0xae, 0xd6, 0x37, 0x15, 0xd6, 0x2e, 0x76, 0x26, 0x6f, 0xf, 0x3b, 0x50, 0x8b, 0x1, 0xa, 0x34}, }, { Name: "test_journal.c", Mode: 0x81a4, - Hash: core.Hash{0xe8, 0x70, 0x1a, 0x4e, 0xea, 0xdb, 0x8e, 0xad, 0x16, 0x9d, 0x60, 0x6, 0x40, 0x7d, 0x54, 0xa8, 0x98, 0x59, 0x2d, 0x70}, + Hash: plumbing.Hash{0xe8, 0x70, 0x1a, 0x4e, 0xea, 0xdb, 0x8e, 0xad, 0x16, 0x9d, 0x60, 0x6, 0x40, 0x7d, 0x54, 0xa8, 0x98, 0x59, 0x2d, 0x70}, }, { Name: "test_loadext.c", Mode: 0x81a4, - Hash: core.Hash{0x11, 0x37, 0xe3, 0xa9, 0xaa, 0xe9, 0x29, 0x6, 0xb8, 0x28, 0x9f, 0x6c, 0x3d, 0xaa, 0x61, 0xf0, 0xd0, 0x70, 0xf5, 0x5a}, + Hash: plumbing.Hash{0x11, 0x37, 0xe3, 0xa9, 0xaa, 0xe9, 0x29, 0x6, 0xb8, 0x28, 0x9f, 0x6c, 0x3d, 0xaa, 0x61, 0xf0, 0xd0, 0x70, 0xf5, 0x5a}, }, { Name: "test_malloc.c", Mode: 0x81a4, - Hash: core.Hash{0xcf, 0x98, 0xa8, 0xfb, 0x21, 0x82, 0xc0, 0xba, 0xf5, 0xa, 0xd5, 0x79, 0x79, 0xb6, 0x75, 0xbb, 0x70, 0x7a, 0x93, 0xb0}, + Hash: plumbing.Hash{0xcf, 0x98, 0xa8, 0xfb, 0x21, 0x82, 0xc0, 0xba, 0xf5, 0xa, 0xd5, 0x79, 0x79, 0xb6, 0x75, 0xbb, 0x70, 0x7a, 0x93, 0xb0}, }, { Name: "test_multiplex.c", Mode: 0x81a4, - Hash: core.Hash{0x62, 0x45, 0x41, 0xb3, 0x2a, 0x10, 0xd2, 0x1a, 0x2f, 0xd1, 0xa, 0x35, 0xee, 0x66, 0x32, 0xbd, 0xac, 0x55, 0x2d, 0x41}, + Hash: plumbing.Hash{0x62, 0x45, 0x41, 0xb3, 0x2a, 0x10, 0xd2, 0x1a, 0x2f, 0xd1, 0xa, 0x35, 0xee, 0x66, 0x32, 0xbd, 0xac, 0x55, 0x2d, 0x41}, }, { Name: "test_multiplex.h", Mode: 0x81a4, - Hash: core.Hash{0xb7, 0xe1, 0xaf, 0xea, 0x5f, 0xd7, 0x8b, 0x87, 0x58, 0x2, 0x65, 0xf8, 0x4c, 0x81, 0x61, 0x2c, 0xbd, 0x2, 0x5b, 0xaf}, + Hash: plumbing.Hash{0xb7, 0xe1, 0xaf, 0xea, 0x5f, 0xd7, 0x8b, 0x87, 0x58, 0x2, 0x65, 0xf8, 0x4c, 0x81, 0x61, 0x2c, 0xbd, 0x2, 0x5b, 0xaf}, }, { Name: "test_mutex.c", Mode: 0x81a4, - Hash: core.Hash{0xc9, 0xb4, 0xa2, 0x9a, 0xb7, 0x5c, 0x77, 0xea, 0x5f, 0x36, 0xb5, 0x19, 0x32, 0x56, 0xd7, 0xf, 0xe6, 0x58, 0xe, 0x95}, + Hash: plumbing.Hash{0xc9, 0xb4, 0xa2, 0x9a, 0xb7, 0x5c, 0x77, 0xea, 0x5f, 0x36, 0xb5, 0x19, 0x32, 0x56, 0xd7, 0xf, 0xe6, 0x58, 0xe, 0x95}, }, { Name: "test_onefile.c", Mode: 0x81a4, - Hash: core.Hash{0x69, 0x86, 0x74, 0x41, 0xb8, 0xcc, 0x9a, 0x62, 0x1a, 0xf3, 0x24, 0x13, 0xfc, 0x63, 0xda, 0x80, 0x99, 0x37, 0x64, 0xf4}, + Hash: plumbing.Hash{0x69, 0x86, 0x74, 0x41, 0xb8, 0xcc, 0x9a, 0x62, 0x1a, 0xf3, 0x24, 0x13, 0xfc, 0x63, 0xda, 0x80, 0x99, 0x37, 0x64, 0xf4}, }, { Name: "test_osinst.c", Mode: 0x81a4, - Hash: core.Hash{0x53, 0x14, 0x33, 0x31, 0x3e, 0xe3, 0x6c, 0x7, 0xeb, 0x21, 0xc0, 0x2f, 0x31, 0x15, 0xcb, 0x7a, 0x37, 0x48, 0x6c, 0x79}, + Hash: plumbing.Hash{0x53, 0x14, 0x33, 0x31, 0x3e, 0xe3, 0x6c, 0x7, 0xeb, 0x21, 0xc0, 0x2f, 0x31, 0x15, 0xcb, 0x7a, 0x37, 0x48, 0x6c, 0x79}, }, { Name: "test_pcache.c", Mode: 0x81a4, - Hash: core.Hash{0x8f, 0xcf, 0xe7, 0xe2, 0x6e, 0x3f, 0xf1, 0x74, 0x96, 0xb8, 0x40, 0xf5, 0xd6, 0x3c, 0x75, 0x78, 0x3a, 0xff, 0x81, 0x62}, + Hash: plumbing.Hash{0x8f, 0xcf, 0xe7, 0xe2, 0x6e, 0x3f, 0xf1, 0x74, 0x96, 0xb8, 0x40, 0xf5, 0xd6, 0x3c, 0x75, 0x78, 0x3a, 0xff, 0x81, 0x62}, }, - {Name: "test_quota.c", Mode: 0x81a4, Hash: core.Hash{ + {Name: "test_quota.c", Mode: 0x81a4, Hash: plumbing.Hash{ 0xe5, 0x90, 0x99, 0x6c, 0xa4, 0xb8, 0x57, 0x4a, 0xb1, 0xe4, 0x18, 0x5d, 0x57, 0x77, 0x56, 0x66, 0x4a, 0xd2, 0x49, 0x5f}}, {Name: "test_quota.h", Mode: 0x81a4, - Hash: core.Hash{0x2d, 0x7, 0x67, 0xa1, 0x9a, 0xb7, 0xc3, 0xa4, 0x21, 0xcd, 0xba, 0x6a, 0x3, 0x49, 0x20, 0x43, 0x67, 0xc2, 0x2c, 0x81}, + Hash: plumbing.Hash{0x2d, 0x7, 0x67, 0xa1, 0x9a, 0xb7, 0xc3, 0xa4, 0x21, 0xcd, 0xba, 0x6a, 0x3, 0x49, 0x20, 0x43, 0x67, 0xc2, 0x2c, 0x81}, }, { Name: "test_rtree.c", Mode: 0x81a4, - Hash: core.Hash{0xf5, 0x4a, 0xe9, 0xb0, 0x63, 0xbb, 0x73, 0x71, 0x2f, 0xcf, 0xc1, 0xc6, 0x83, 0x2e, 0x2a, 0x50, 0xf6, 0x2a, 0x97, 0xe7}, + Hash: plumbing.Hash{0xf5, 0x4a, 0xe9, 0xb0, 0x63, 0xbb, 0x73, 0x71, 0x2f, 0xcf, 0xc1, 0xc6, 0x83, 0x2e, 0x2a, 0x50, 0xf6, 0x2a, 0x97, 0xe7}, }, { Name: "test_schema.c", Mode: 0x81a4, - Hash: core.Hash{0x12, 0x64, 0x44, 0x67, 0x64, 0x7d, 0x51, 0x39, 0x4a, 0x1, 0xf9, 0xfa, 0x60, 0x37, 0x62, 0x98, 0x18, 0x54, 0x66, 0xfd}, + Hash: plumbing.Hash{0x12, 0x64, 0x44, 0x67, 0x64, 0x7d, 0x51, 0x39, 0x4a, 0x1, 0xf9, 0xfa, 0x60, 0x37, 0x62, 0x98, 0x18, 0x54, 0x66, 0xfd}, }, { Name: "test_server.c", Mode: 0x81a4, - Hash: core.Hash{0xed, 0x8, 0x18, 0xe6, 0xf6, 0x5f, 0x27, 0x28, 0x2d, 0xc7, 0xb1, 0xc1, 0x90, 0xec, 0x18, 0x8c, 0x89, 0x33, 0x0, 0x2b}, + Hash: plumbing.Hash{0xed, 0x8, 0x18, 0xe6, 0xf6, 0x5f, 0x27, 0x28, 0x2d, 0xc7, 0xb1, 0xc1, 0x90, 0xec, 0x18, 0x8c, 0x89, 0x33, 0x0, 0x2b}, }, { Name: "test_sqllog.c", Mode: 0x81a4, - Hash: core.Hash{0x4a, 0xa6, 0x8b, 0x7c, 0x42, 0x93, 0x23, 0xb8, 0xee, 0xbe, 0x6c, 0x9c, 0x2d, 0x7, 0xfc, 0x66, 0xd, 0x8d, 0x47, 0xc9}, + Hash: plumbing.Hash{0x4a, 0xa6, 0x8b, 0x7c, 0x42, 0x93, 0x23, 0xb8, 0xee, 0xbe, 0x6c, 0x9c, 0x2d, 0x7, 0xfc, 0x66, 0xd, 0x8d, 0x47, 0xc9}, }, { Name: "test_stat.c", Mode: 0x81a4, - Hash: core.Hash{0xd4, 0xc9, 0x2, 0xb5, 0xea, 0x11, 0x1a, 0xd5, 0x8a, 0x73, 0x71, 0x12, 0xc2, 0x8f, 0x0, 0x38, 0x43, 0x4c, 0x85, 0xc0}, + Hash: plumbing.Hash{0xd4, 0xc9, 0x2, 0xb5, 0xea, 0x11, 0x1a, 0xd5, 0x8a, 0x73, 0x71, 0x12, 0xc2, 0x8f, 0x0, 0x38, 0x43, 0x4c, 0x85, 0xc0}, }, { Name: "test_superlock.c", Mode: 0x81a4, - Hash: core.Hash{0x93, 0x6f, 0xca, 0xd0, 0xc5, 0x6f, 0x6b, 0xc8, 0x58, 0x9, 0x74, 0x2f, 0x6a, 0xe1, 0xc1, 0xee, 0xb8, 0xb7, 0xd2, 0xf1}, + Hash: plumbing.Hash{0x93, 0x6f, 0xca, 0xd0, 0xc5, 0x6f, 0x6b, 0xc8, 0x58, 0x9, 0x74, 0x2f, 0x6a, 0xe1, 0xc1, 0xee, 0xb8, 0xb7, 0xd2, 0xf1}, }, { Name: "test_syscall.c", Mode: 0x81a4, - Hash: core.Hash{0x7c, 0x8, 0x73, 0xc1, 0x6d, 0x84, 0x32, 0x2, 0xf3, 0xe, 0x2d, 0xb9, 0x45, 0x9f, 0xa2, 0x99, 0x75, 0xea, 0x5e, 0x68}, + Hash: plumbing.Hash{0x7c, 0x8, 0x73, 0xc1, 0x6d, 0x84, 0x32, 0x2, 0xf3, 0xe, 0x2d, 0xb9, 0x45, 0x9f, 0xa2, 0x99, 0x75, 0xea, 0x5e, 0x68}, }, { Name: "test_tclvar.c", Mode: 0x81a4, - Hash: core.Hash{0x12, 0x19, 0x19, 0xc, 0x3, 0x0, 0xfd, 0x5e, 0xc7, 0xa3, 0xc5, 0x84, 0x8, 0xf3, 0x38, 0x43, 0xd2, 0xe, 0xee, 0x15}, + Hash: plumbing.Hash{0x12, 0x19, 0x19, 0xc, 0x3, 0x0, 0xfd, 0x5e, 0xc7, 0xa3, 0xc5, 0x84, 0x8, 0xf3, 0x38, 0x43, 0xd2, 0xe, 0xee, 0x15}, }, { Name: "test_thread.c", Mode: 0x81a4, - Hash: core.Hash{0x2f, 0x93, 0x63, 0xb7, 0x50, 0x1e, 0x51, 0x19, 0x81, 0xfe, 0x32, 0x83, 0x1f, 0xf2, 0xe8, 0xfd, 0x2f, 0x30, 0xc4, 0x93}, + Hash: plumbing.Hash{0x2f, 0x93, 0x63, 0xb7, 0x50, 0x1e, 0x51, 0x19, 0x81, 0xfe, 0x32, 0x83, 0x1f, 0xf2, 0xe8, 0xfd, 0x2f, 0x30, 0xc4, 0x93}, }, { Name: "test_vfs.c", Mode: 0x81a4, - Hash: core.Hash{0xfc, 0xd5, 0x77, 0x43, 0x9c, 0xfd, 0x6c, 0x72, 0xdd, 0xe4, 0x83, 0x58, 0x92, 0x14, 0x20, 0xcf, 0x6e, 0xf1, 0xf8, 0x6d}, + Hash: plumbing.Hash{0xfc, 0xd5, 0x77, 0x43, 0x9c, 0xfd, 0x6c, 0x72, 0xdd, 0xe4, 0x83, 0x58, 0x92, 0x14, 0x20, 0xcf, 0x6e, 0xf1, 0xf8, 0x6d}, }, { Name: "test_vfstrace.c", Mode: 0x81a4, - Hash: core.Hash{0xa, 0xac, 0xc0, 0x1f, 0xe4, 0x2e, 0x77, 0xfe, 0xb8, 0x58, 0xe4, 0xbe, 0xd0, 0xcb, 0x7e, 0x4, 0xa4, 0x35, 0xb2, 0x10}, + Hash: plumbing.Hash{0xa, 0xac, 0xc0, 0x1f, 0xe4, 0x2e, 0x77, 0xfe, 0xb8, 0x58, 0xe4, 0xbe, 0xd0, 0xcb, 0x7e, 0x4, 0xa4, 0x35, 0xb2, 0x10}, }, { Name: "test_wsd.c", Mode: 0x81a4, - Hash: core.Hash{0x99, 0xe4, 0xa0, 0x56, 0x58, 0x1f, 0x58, 0xf4, 0x53, 0x6f, 0xdb, 0x5a, 0x5d, 0xf7, 0x5c, 0x74, 0x69, 0x8a, 0x81, 0x62}, + Hash: plumbing.Hash{0x99, 0xe4, 0xa0, 0x56, 0x58, 0x1f, 0x58, 0xf4, 0x53, 0x6f, 0xdb, 0x5a, 0x5d, 0xf7, 0x5c, 0x74, 0x69, 0x8a, 0x81, 0x62}, }, { Name: "tokenize.c", Mode: 0x81a4, - Hash: core.Hash{0xfa, 0xea, 0x5f, 0x26, 0xc7, 0x9c, 0x5e, 0x18, 0x8f, 0xa8, 0x7f, 0x2f, 0xdf, 0x6f, 0xf7, 0x6a, 0x7a, 0x60, 0x6, 0xc5}, + Hash: plumbing.Hash{0xfa, 0xea, 0x5f, 0x26, 0xc7, 0x9c, 0x5e, 0x18, 0x8f, 0xa8, 0x7f, 0x2f, 0xdf, 0x6f, 0xf7, 0x6a, 0x7a, 0x60, 0x6, 0xc5}, }, { Name: "trigger.c", Mode: 0x81a4, - Hash: core.Hash{0xf1, 0xff, 0x76, 0x6e, 0x20, 0x2a, 0x45, 0x18, 0xec, 0x10, 0xe5, 0x27, 0x12, 0xc, 0xd3, 0xe, 0x83, 0xfb, 0xd0, 0x34}, + Hash: plumbing.Hash{0xf1, 0xff, 0x76, 0x6e, 0x20, 0x2a, 0x45, 0x18, 0xec, 0x10, 0xe5, 0x27, 0x12, 0xc, 0xd3, 0xe, 0x83, 0xfb, 0xd0, 0x34}, }, { Name: "update.c", Mode: 0x81a4, - Hash: core.Hash{0x3a, 0xb1, 0xab, 0x2a, 0x4b, 0x65, 0xda, 0x3f, 0x19, 0x8c, 0x15, 0x84, 0xd5, 0x4d, 0x36, 0xf1, 0x8c, 0xa1, 0x21, 0x4a}, + Hash: plumbing.Hash{0x3a, 0xb1, 0xab, 0x2a, 0x4b, 0x65, 0xda, 0x3f, 0x19, 0x8c, 0x15, 0x84, 0xd5, 0x4d, 0x36, 0xf1, 0x8c, 0xa1, 0x21, 0x4a}, }, { Name: "utf.c", Mode: 0x81a4, - Hash: core.Hash{0x6d, 0x5b, 0x1b, 0xfe, 0x40, 0xc, 0x37, 0x48, 0xaa, 0x70, 0xa3, 0xb2, 0xfd, 0x5e, 0xe, 0xac, 0x5f, 0xc0, 0x4d, 0xe2}, + Hash: plumbing.Hash{0x6d, 0x5b, 0x1b, 0xfe, 0x40, 0xc, 0x37, 0x48, 0xaa, 0x70, 0xa3, 0xb2, 0xfd, 0x5e, 0xe, 0xac, 0x5f, 0xc0, 0x4d, 0xe2}, }, { Name: "util.c", Mode: 0x81a4, - Hash: core.Hash{0xd8, 0x3a, 0x63, 0x1, 0x5f, 0xd8, 0x7d, 0xcc, 0x4f, 0xb4, 0x41, 0x66, 0xfa, 0xbf, 0x2e, 0x9b, 0xc9, 0x67, 0x1e, 0xb8}, + Hash: plumbing.Hash{0xd8, 0x3a, 0x63, 0x1, 0x5f, 0xd8, 0x7d, 0xcc, 0x4f, 0xb4, 0x41, 0x66, 0xfa, 0xbf, 0x2e, 0x9b, 0xc9, 0x67, 0x1e, 0xb8}, }, { Name: "vacuum.c", Mode: 0x81a4, - Hash: core.Hash{0x4a, 0xfb, 0x2c, 0xca, 0x64, 0xdd, 0x60, 0x76, 0x11, 0x22, 0x2c, 0x7, 0x93, 0x2d, 0x12, 0xea, 0xcf, 0xa, 0x2c, 0x22}, + Hash: plumbing.Hash{0x4a, 0xfb, 0x2c, 0xca, 0x64, 0xdd, 0x60, 0x76, 0x11, 0x22, 0x2c, 0x7, 0x93, 0x2d, 0x12, 0xea, 0xcf, 0xa, 0x2c, 0x22}, }, { Name: "vdbe.c", Mode: 0x81a4, - Hash: core.Hash{0xf3, 0x43, 0xe1, 0x3d, 0x4e, 0x91, 0x78, 0x4b, 0x15, 0x88, 0x10, 0xc5, 0xb7, 0xd4, 0x46, 0x84, 0xdf, 0xbf, 0xa2, 0xa5}, + Hash: plumbing.Hash{0xf3, 0x43, 0xe1, 0x3d, 0x4e, 0x91, 0x78, 0x4b, 0x15, 0x88, 0x10, 0xc5, 0xb7, 0xd4, 0x46, 0x84, 0xdf, 0xbf, 0xa2, 0xa5}, }, { Name: "vdbe.h", Mode: 0x81a4, - Hash: core.Hash{0xfa, 0x7b, 0x31, 0xb7, 0x27, 0xa, 0x90, 0xd4, 0xf6, 0x37, 0x36, 0x5a, 0xfc, 0xc9, 0xbd, 0xa1, 0xd1, 0xb1, 0xe1, 0xd6}, + Hash: plumbing.Hash{0xfa, 0x7b, 0x31, 0xb7, 0x27, 0xa, 0x90, 0xd4, 0xf6, 0x37, 0x36, 0x5a, 0xfc, 0xc9, 0xbd, 0xa1, 0xd1, 0xb1, 0xe1, 0xd6}, }, { Name: "vdbeInt.h", Mode: 0x81a4, - Hash: core.Hash{0x3a, 0x5b, 0x40, 0x28, 0xbb, 0xd6, 0xc9, 0x56, 0x10, 0xd7, 0xc, 0xce, 0x3, 0x69, 0xdf, 0xcd, 0x60, 0x7a, 0xa9, 0x0}, + Hash: plumbing.Hash{0x3a, 0x5b, 0x40, 0x28, 0xbb, 0xd6, 0xc9, 0x56, 0x10, 0xd7, 0xc, 0xce, 0x3, 0x69, 0xdf, 0xcd, 0x60, 0x7a, 0xa9, 0x0}, }, { Name: "vdbeapi.c", Mode: 0x81a4, - Hash: core.Hash{0x7c, 0x86, 0x1e, 0x2d, 0x47, 0x21, 0x8c, 0x91, 0x63, 0x31, 0x77, 0x77, 0xc3, 0x7, 0x21, 0x99, 0xe9, 0xb4, 0x2, 0x80}, + Hash: plumbing.Hash{0x7c, 0x86, 0x1e, 0x2d, 0x47, 0x21, 0x8c, 0x91, 0x63, 0x31, 0x77, 0x77, 0xc3, 0x7, 0x21, 0x99, 0xe9, 0xb4, 0x2, 0x80}, }, { Name: "vdbeaux.c", Mode: 0x81a4, - Hash: core.Hash{0x2c, 0x42, 0x69, 0xa5, 0x9e, 0x6d, 0xbc, 0xe8, 0x67, 0x1c, 0x47, 0x4f, 0x34, 0x61, 0x90, 0xbe, 0x2a, 0xe, 0x18, 0x51}, + Hash: plumbing.Hash{0x2c, 0x42, 0x69, 0xa5, 0x9e, 0x6d, 0xbc, 0xe8, 0x67, 0x1c, 0x47, 0x4f, 0x34, 0x61, 0x90, 0xbe, 0x2a, 0xe, 0x18, 0x51}, }, { Name: "vdbeblob.c", Mode: 0x81a4, - Hash: core.Hash{0x2e, 0x8f, 0xd8, 0xee, 0x74, 0x47, 0xe6, 0x46, 0x46, 0xe3, 0x49, 0x4b, 0x4c, 0x4, 0x1d, 0x3a, 0x4a, 0xbb, 0x8, 0x85}, + Hash: plumbing.Hash{0x2e, 0x8f, 0xd8, 0xee, 0x74, 0x47, 0xe6, 0x46, 0x46, 0xe3, 0x49, 0x4b, 0x4c, 0x4, 0x1d, 0x3a, 0x4a, 0xbb, 0x8, 0x85}, }, { Name: "vdbemem.c", Mode: 0x81a4, - Hash: core.Hash{0x8f, 0xc2, 0x22, 0xe2, 0xde, 0x20, 0x50, 0x14, 0x50, 0xec, 0xea, 0x9d, 0x4e, 0xbf, 0xaa, 0xc9, 0x81, 0x4a, 0xae, 0x59}, + Hash: plumbing.Hash{0x8f, 0xc2, 0x22, 0xe2, 0xde, 0x20, 0x50, 0x14, 0x50, 0xec, 0xea, 0x9d, 0x4e, 0xbf, 0xaa, 0xc9, 0x81, 0x4a, 0xae, 0x59}, }, { Name: "vdbesort.c", Mode: 0x81a4, - Hash: core.Hash{0xfd, 0xfc, 0x4a, 0x79, 0xdd, 0xc9, 0x6e, 0x59, 0x9b, 0x1b, 0xe, 0xeb, 0xac, 0xbd, 0xb8, 0x45, 0xc6, 0x38, 0x13, 0xb2}, + Hash: plumbing.Hash{0xfd, 0xfc, 0x4a, 0x79, 0xdd, 0xc9, 0x6e, 0x59, 0x9b, 0x1b, 0xe, 0xeb, 0xac, 0xbd, 0xb8, 0x45, 0xc6, 0x38, 0x13, 0xb2}, }, { Name: "vdbetrace.c", Mode: 0x81a4, - Hash: core.Hash{0x35, 0x62, 0x77, 0xe8, 0xd2, 0x3b, 0xca, 0xdb, 0x67, 0x6b, 0x59, 0xd1, 0xa4, 0xdc, 0xf8, 0x42, 0xfd, 0xc4, 0xc9, 0x72}, + Hash: plumbing.Hash{0x35, 0x62, 0x77, 0xe8, 0xd2, 0x3b, 0xca, 0xdb, 0x67, 0x6b, 0x59, 0xd1, 0xa4, 0xdc, 0xf8, 0x42, 0xfd, 0xc4, 0xc9, 0x72}, }, { Name: "vtab.c", Mode: 0x81a4, - Hash: core.Hash{0x95, 0x82, 0x2, 0xc3, 0x1e, 0x24, 0x15, 0xb, 0x60, 0xf1, 0xa, 0x8a, 0xf, 0x74, 0x41, 0xaf, 0xac, 0x3f, 0xbb, 0x1c}, + Hash: plumbing.Hash{0x95, 0x82, 0x2, 0xc3, 0x1e, 0x24, 0x15, 0xb, 0x60, 0xf1, 0xa, 0x8a, 0xf, 0x74, 0x41, 0xaf, 0xac, 0x3f, 0xbb, 0x1c}, }, { Name: "wal.c", Mode: 0x81a4, - Hash: core.Hash{0xe6, 0x42, 0xea, 0x21, 0x5, 0xb5, 0xc5, 0x4a, 0xf3, 0x5, 0x88, 0x9, 0x62, 0x69, 0xab, 0x75, 0xcb, 0xef, 0x8f, 0xf2}, + Hash: plumbing.Hash{0xe6, 0x42, 0xea, 0x21, 0x5, 0xb5, 0xc5, 0x4a, 0xf3, 0x5, 0x88, 0x9, 0x62, 0x69, 0xab, 0x75, 0xcb, 0xef, 0x8f, 0xf2}, }, { Name: "wal.h", Mode: 0x81a4, - Hash: core.Hash{0x9, 0x25, 0x46, 0x35, 0x4b, 0x34, 0xc0, 0xab, 0x3d, 0x20, 0x5, 0x6a, 0x7f, 0x8a, 0x8a, 0x52, 0xe4, 0xd0, 0xb5, 0xf5}, + Hash: plumbing.Hash{0x9, 0x25, 0x46, 0x35, 0x4b, 0x34, 0xc0, 0xab, 0x3d, 0x20, 0x5, 0x6a, 0x7f, 0x8a, 0x8a, 0x52, 0xe4, 0xd0, 0xb5, 0xf5}, }, { Name: "walker.c", Mode: 0x81a4, - Hash: core.Hash{0xe7, 0x1e, 0xd2, 0xac, 0x48, 0x4c, 0x91, 0x6c, 0x1c, 0xc1, 0x0, 0x7e, 0x5e, 0x5, 0xda, 0x47, 0x1c, 0xb4, 0x95, 0x99}, + Hash: plumbing.Hash{0xe7, 0x1e, 0xd2, 0xac, 0x48, 0x4c, 0x91, 0x6c, 0x1c, 0xc1, 0x0, 0x7e, 0x5e, 0x5, 0xda, 0x47, 0x1c, 0xb4, 0x95, 0x99}, }, { Name: "where.c", Mode: 0x81a4, - Hash: core.Hash{0xe6, 0x14, 0xf4, 0xa6, 0xd8, 0x64, 0xe7, 0xe, 0xc4, 0x32, 0x8d, 0xb, 0xdb, 0x25, 0x4e, 0x3a, 0xc9, 0xf0, 0xd2, 0x87}, + Hash: plumbing.Hash{0xe6, 0x14, 0xf4, 0xa6, 0xd8, 0x64, 0xe7, 0xe, 0xc4, 0x32, 0x8d, 0xb, 0xdb, 0x25, 0x4e, 0x3a, 0xc9, 0xf0, 0xd2, 0x87}, }, }, - Hash: core.Hash{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, + Hash: plumbing.Hash{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, r: (*Repository)(nil), m: map[string]*TreeEntry(nil), } diff --git a/utils/binary/read.go b/utils/binary/read.go index 90ae41f..8aab3e5 100644 --- a/utils/binary/read.go +++ b/utils/binary/read.go @@ -6,7 +6,7 @@ import ( "encoding/binary" "io" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) // Read reads structured binary data from r into data. Bytes are read and @@ -113,11 +113,11 @@ func ReadUint16(r io.Reader) (uint16, error) { return v, nil } -// ReadHash reads a core.Hash from r -func ReadHash(r io.Reader) (core.Hash, error) { - var h core.Hash +// ReadHash reads a plumbing.Hash from r +func ReadHash(r io.Reader) (plumbing.Hash, error) { + var h plumbing.Hash if err := binary.Read(r, binary.BigEndian, h[:]); err != nil { - return core.ZeroHash, err + return plumbing.ZeroHash, err } return h, nil diff --git a/utils/binary/read_test.go b/utils/binary/read_test.go index ad5ef29..59dbc30 100644 --- a/utils/binary/read_test.go +++ b/utils/binary/read_test.go @@ -6,7 +6,7 @@ import ( "testing" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) func Test(t *testing.T) { TestingT(t) } @@ -76,7 +76,7 @@ func (s *BinarySuite) TestReadUint16(c *C) { } func (s *BinarySuite) TestReadHash(c *C) { - expected := core.NewHash("43aec75c611f22c73b27ece2841e6ccca592f285") + expected := plumbing.NewHash("43aec75c611f22c73b27ece2841e6ccca592f285") buf := bytes.NewBuffer(nil) err := binary.Write(buf, binary.BigEndian, expected) c.Assert(err, IsNil) |