diff options
Diffstat (limited to 'storage/filesystem')
-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 |
7 files changed, 112 insertions, 110 deletions
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 } |