diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2015-10-31 01:14:03 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2015-10-31 01:14:03 +0100 |
commit | c6349552c1c54ea114b92ae23fc840f68f6551f4 (patch) | |
tree | 6fbaf514ae9caf8241a0b9dfc3709d60942876c5 /formats/packfile | |
parent | fe1fc1aa7dca3e0f6e54ab17f0acfa45f269e58c (diff) | |
download | go-git-c6349552c1c54ea114b92ae23fc840f68f6551f4.tar.gz |
internal -> core
Diffstat (limited to 'formats/packfile')
-rw-r--r-- | formats/packfile/reader.go | 28 | ||||
-rw-r--r-- | formats/packfile/reader_test.go | 14 |
2 files changed, 21 insertions, 21 deletions
diff --git a/formats/packfile/reader.go b/formats/packfile/reader.go index 420b9cd..3ff342f 100644 --- a/formats/packfile/reader.go +++ b/formats/packfile/reader.go @@ -7,7 +7,7 @@ import ( "io" "io/ioutil" - "gopkg.in/src-d/go-git.v2/internal" + "gopkg.in/src-d/go-git.v2/core" "github.com/klauspost/compress/zlib" ) @@ -50,8 +50,8 @@ type Reader struct { Format Format r *trackingReader - s internal.ObjectStorage - offsets map[int64]internal.Hash + s core.ObjectStorage + offsets map[int64]core.Hash } // NewReader returns a new Reader that reads from a io.Reader @@ -60,12 +60,12 @@ func NewReader(r io.Reader) *Reader { MaxObjectsLimit: DefaultMaxObjectsLimit, r: &trackingReader{r: r}, - offsets: make(map[int64]internal.Hash, 0), + offsets: make(map[int64]core.Hash, 0), } } // Read reads the objects and stores it at the ObjectStorage -func (r *Reader) Read(s internal.ObjectStorage) (int64, error) { +func (r *Reader) Read(s core.ObjectStorage) (int64, error) { r.s = s if err := r.validateHeader(); err != nil { if err == io.EOF { @@ -144,7 +144,7 @@ func (r *Reader) readObjects(count uint32) error { return nil } -func (r *Reader) newRAWObject() (internal.Object, error) { +func (r *Reader) newRAWObject() (core.Object, error) { raw := r.s.New() var steps int64 @@ -153,7 +153,7 @@ func (r *Reader) newRAWObject() (internal.Object, error) { return nil, err } - typ := internal.ObjectType((buf[0] >> 4) & 7) + typ := core.ObjectType((buf[0] >> 4) & 7) size := int64(buf[0] & 15) steps++ // byte we just read to get `o.typ` and `o.size` @@ -173,11 +173,11 @@ func (r *Reader) newRAWObject() (internal.Object, error) { var err error switch raw.Type() { - case internal.REFDeltaObject: + case core.REFDeltaObject: err = r.readREFDelta(raw) - case internal.OFSDeltaObject: + case core.OFSDeltaObject: err = r.readOFSDelta(raw, steps) - case internal.CommitObject, internal.TreeObject, internal.BlobObject, internal.TagObject: + case core.CommitObject, core.TreeObject, core.BlobObject, core.TagObject: err = r.readObject(raw) default: err = InvalidObjectErr.n("tag %q", raw.Type) @@ -186,8 +186,8 @@ func (r *Reader) newRAWObject() (internal.Object, error) { return raw, err } -func (r *Reader) readREFDelta(raw internal.Object) error { - var ref internal.Hash +func (r *Reader) readREFDelta(raw core.Object) error { + var ref core.Hash if _, err := r.r.Read(ref[:]); err != nil { return err } @@ -215,7 +215,7 @@ func (r *Reader) readREFDelta(raw internal.Object) error { return nil } -func (r *Reader) readOFSDelta(raw internal.Object, steps int64) error { +func (r *Reader) readOFSDelta(raw core.Object, steps int64) error { start := r.r.position offset, err := decodeOffset(r.r, steps) if err != nil { @@ -246,7 +246,7 @@ func (r *Reader) readOFSDelta(raw internal.Object, steps int64) error { return nil } -func (r *Reader) readObject(raw internal.Object) error { +func (r *Reader) readObject(raw core.Object) error { return r.inflate(raw.Writer()) } diff --git a/formats/packfile/reader_test.go b/formats/packfile/reader_test.go index f5cc3e7..8561a59 100644 --- a/formats/packfile/reader_test.go +++ b/formats/packfile/reader_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "gopkg.in/src-d/go-git.v2/internal" + "gopkg.in/src-d/go-git.v2/core" "github.com/dustin/go-humanize" . "gopkg.in/check.v1" @@ -29,7 +29,7 @@ func (s *ReaderSuite) TestReadPackfile(c *C) { r := NewReader(d) - storage := internal.NewRAWObjectStorage() + storage := core.NewRAWObjectStorage() _, err := r.Read(storage) c.Assert(err, IsNil) @@ -63,7 +63,7 @@ func (s *ReaderSuite) testReadPackfileGitFixture(c *C, file string, f Format) { r := NewReader(d) r.Format = f - storage := internal.NewRAWObjectStorage() + storage := core.NewRAWObjectStorage() _, err = r.Read(storage) c.Assert(err, IsNil) @@ -99,10 +99,10 @@ func (s *ReaderSuite) testReadPackfileGitFixture(c *C, file string, f Format) { }) } -func AssertObjects(c *C, s *internal.RAWObjectStorage, expects []string) { +func AssertObjects(c *C, s *core.RAWObjectStorage, expects []string) { c.Assert(len(expects), Equals, len(s.Objects)) for _, expected := range expects { - obtained, ok := s.Get(internal.NewHash(expected)) + obtained, ok := s.Get(core.NewHash(expected)) c.Assert(ok, Equals, true) c.Assert(obtained.Hash().String(), Equals, expected) } @@ -174,14 +174,14 @@ func (s *ReaderSuite) _TestMemoryREF(c *C) { fmt.Println("time", time.Since(start)) } -func readFromFile(c *C, file string, f Format) *internal.RAWObjectStorage { +func readFromFile(c *C, file string, f Format) *core.RAWObjectStorage { d, err := os.Open(file) c.Assert(err, IsNil) r := NewReader(d) r.Format = f - storage := internal.NewRAWObjectStorage() + storage := core.NewRAWObjectStorage() _, err = r.Read(storage) c.Assert(err, IsNil) |