aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clients/common/common.go50
-rw-r--r--clients/common/common_test.go16
-rw-r--r--clients/http/common.go5
-rw-r--r--clients/http/git_upload_pack.go7
-rw-r--r--clients/http/git_upload_pack_test.go6
-rw-r--r--commit.go26
-rw-r--r--common_test.go6
-rw-r--r--core/errors.go35
-rw-r--r--core/hash.go (renamed from internal/hash.go)2
-rw-r--r--core/hash_test.go (renamed from internal/hash_test.go)2
-rw-r--r--core/object.go (renamed from internal/object.go)2
-rw-r--r--formats/packfile/reader.go28
-rw-r--r--formats/packfile/reader_test.go14
-rw-r--r--objects.go10
-rw-r--r--objects_test.go10
-rw-r--r--remote.go10
-rw-r--r--remote_test.go4
-rw-r--r--repository.go12
-rw-r--r--repository_test.go4
-rw-r--r--tree.go14
20 files changed, 135 insertions, 128 deletions
diff --git a/clients/common/common.go b/clients/common/common.go
index 105e242..2c9a37e 100644
--- a/clients/common/common.go
+++ b/clients/common/common.go
@@ -7,8 +7,8 @@ import (
"net/url"
"strings"
+ "gopkg.in/src-d/go-git.v2/core"
"gopkg.in/src-d/go-git.v2/formats/pktline"
- "gopkg.in/src-d/go-git.v2/internal"
"gopkg.in/sourcegraph/go-vcsurl.v1"
)
@@ -25,7 +25,7 @@ type Endpoint string
func NewEndpoint(url string) (Endpoint, error) {
vcs, err := vcsurl.Parse(url)
if err != nil {
- return "", NewPermanentError(err)
+ return "", core.NewPermanentError(err)
}
link := vcs.Link()
@@ -118,17 +118,17 @@ func (r Capabilities) SymbolicReference(sym string) string {
type GitUploadPackInfo struct {
Capabilities Capabilities
Head string
- Refs map[string]internal.Hash
+ Refs map[string]core.Hash
}
func NewGitUploadPackInfo(d *pktline.Decoder) (*GitUploadPackInfo, error) {
info := &GitUploadPackInfo{}
if err := info.read(d); err != nil {
if err == EmptyGitUploadPackErr {
- return nil, NewPermanentError(err)
+ return nil, core.NewPermanentError(err)
}
- return nil, NewUnexpectedError(err)
+ return nil, core.NewUnexpectedError(err)
}
return info, nil
@@ -141,7 +141,7 @@ func (r *GitUploadPackInfo) read(d *pktline.Decoder) error {
}
isEmpty := true
- r.Refs = map[string]internal.Hash{}
+ r.Refs = map[string]core.Hash{}
for _, line := range lines {
if !r.isValidLine(line) {
continue
@@ -178,7 +178,7 @@ func (r *GitUploadPackInfo) readLine(line string) {
return
}
- r.Refs[parts[1]] = internal.NewHash(parts[0])
+ r.Refs[parts[1]] = core.NewHash(parts[0])
}
func (r *GitUploadPackInfo) String() string {
@@ -201,8 +201,8 @@ func (r *GitUploadPackInfo) Bytes() []byte {
}
type GitUploadPackRequest struct {
- Want []internal.Hash
- Have []internal.Hash
+ Want []core.Hash
+ Have []core.Hash
}
func (r *GitUploadPackRequest) String() string {
@@ -225,35 +225,3 @@ func (r *GitUploadPackRequest) Reader() *strings.Reader {
return e.Reader()
}
-
-type PermanentError struct {
- err error
-}
-
-func NewPermanentError(err error) *PermanentError {
- if err == nil {
- return nil
- }
-
- return &PermanentError{err: err}
-}
-
-func (e *PermanentError) Error() string {
- return fmt.Sprintf("permanent client error: %s", e.err.Error())
-}
-
-type UnexpectedError struct {
- err error
-}
-
-func NewUnexpectedError(err error) *UnexpectedError {
- if err == nil {
- return nil
- }
-
- return &UnexpectedError{err: err}
-}
-
-func (e *UnexpectedError) Error() string {
- return fmt.Sprintf("unexpected client error: %s", e.err.Error())
-}
diff --git a/clients/common/common_test.go b/clients/common/common_test.go
index ab2de7c..494a03a 100644
--- a/clients/common/common_test.go
+++ b/clients/common/common_test.go
@@ -6,8 +6,8 @@ import (
"testing"
. "gopkg.in/check.v1"
+ "gopkg.in/src-d/go-git.v2/core"
"gopkg.in/src-d/go-git.v2/formats/pktline"
- "gopkg.in/src-d/go-git.v2/internal"
)
func Test(t *testing.T) { TestingT(t) }
@@ -82,8 +82,8 @@ func (s *SuiteCommon) TestGitUploadPackEncode(c *C) {
}
info.Head = "refs/heads/master"
- info.Refs = map[string]internal.Hash{
- "refs/heads/master": internal.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
+ info.Refs = map[string]core.Hash{
+ "refs/heads/master": core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
}
c.Assert(info.String(), Equals,
@@ -96,12 +96,12 @@ func (s *SuiteCommon) TestGitUploadPackEncode(c *C) {
func (s *SuiteCommon) TestGitUploadPackRequest(c *C) {
r := &GitUploadPackRequest{
- Want: []internal.Hash{
- internal.NewHash("d82f291cde9987322c8a0c81a325e1ba6159684c"),
- internal.NewHash("2b41ef280fdb67a9b250678686a0c3e03b0a9989"),
+ Want: []core.Hash{
+ core.NewHash("d82f291cde9987322c8a0c81a325e1ba6159684c"),
+ core.NewHash("2b41ef280fdb67a9b250678686a0c3e03b0a9989"),
},
- Have: []internal.Hash{
- internal.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
+ Have: []core.Hash{
+ core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
},
}
diff --git a/clients/http/common.go b/clients/http/common.go
index 2a2808c..15338a8 100644
--- a/clients/http/common.go
+++ b/clients/http/common.go
@@ -5,6 +5,7 @@ import (
"net/http"
"gopkg.in/src-d/go-git.v2/clients/common"
+ "gopkg.in/src-d/go-git.v2/core"
)
type HTTPError struct {
@@ -18,10 +19,10 @@ func NewHTTPError(r *http.Response) error {
err := &HTTPError{r}
if r.StatusCode == 404 || r.StatusCode == 401 {
- return common.NewPermanentError(common.NotFoundErr)
+ return core.NewPermanentError(common.NotFoundErr)
}
- return common.NewUnexpectedError(err)
+ return core.NewUnexpectedError(err)
}
func (e *HTTPError) StatusCode() int {
diff --git a/clients/http/git_upload_pack.go b/clients/http/git_upload_pack.go
index 1c22dbf..bc99fd8 100644
--- a/clients/http/git_upload_pack.go
+++ b/clients/http/git_upload_pack.go
@@ -7,6 +7,7 @@ import (
"strings"
"gopkg.in/src-d/go-git.v2/clients/common"
+ "gopkg.in/src-d/go-git.v2/core"
"gopkg.in/src-d/go-git.v2/formats/pktline"
)
@@ -50,7 +51,7 @@ func (s *GitUploadPackService) Fetch(r *common.GitUploadPackRequest) (io.ReadClo
h := make([]byte, 8)
if _, err := res.Body.Read(h); err != nil {
- return nil, common.NewUnexpectedError(err)
+ return nil, core.NewUnexpectedError(err)
}
return res.Body, nil
@@ -64,14 +65,14 @@ func (s *GitUploadPackService) doRequest(method, url string, content *strings.Re
req, err := http.NewRequest(method, url, body)
if err != nil {
- return nil, common.NewPermanentError(err)
+ return nil, core.NewPermanentError(err)
}
s.applyHeadersToRequest(req, content)
res, err := s.Client.Do(req)
if err != nil {
- return nil, common.NewUnexpectedError(err)
+ return nil, core.NewUnexpectedError(err)
}
if err := NewHTTPError(res); err != nil {
diff --git a/clients/http/git_upload_pack_test.go b/clients/http/git_upload_pack_test.go
index 7234766..c90a259 100644
--- a/clients/http/git_upload_pack_test.go
+++ b/clients/http/git_upload_pack_test.go
@@ -5,7 +5,7 @@ import (
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v2/clients/common"
- "gopkg.in/src-d/go-git.v2/internal"
+ "gopkg.in/src-d/go-git.v2/core"
)
type SuiteRemote struct{}
@@ -42,8 +42,8 @@ func (s *SuiteRemote) TestFetch(c *C) {
c.Assert(r.Connect(RepositoryFixture), IsNil)
reader, err := r.Fetch(&common.GitUploadPackRequest{
- Want: []internal.Hash{
- internal.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
+ Want: []core.Hash{
+ core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
},
})
diff --git a/commit.go b/commit.go
index b8a2772..9dce880 100644
--- a/commit.go
+++ b/commit.go
@@ -6,22 +6,24 @@ import (
"fmt"
"io"
- "gopkg.in/src-d/go-git.v2/internal"
+ "gopkg.in/src-d/go-git.v2/core"
)
+type Hash core.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
// in time, such as a timestamp, the author of the changes since the last
// commit, a pointer to the previous commit(s), etc.
// http://schacon.github.io/gitbook/1_the_git_object_model.html
type Commit struct {
- Hash internal.Hash
+ Hash core.Hash
Author Signature
Committer Signature
Message string
- tree internal.Hash
- parents []internal.Hash
+ tree core.Hash
+ parents []core.Hash
r *Repository
}
@@ -43,8 +45,8 @@ func (c *Commit) Parents() *CommitIter {
return i
}
-// Decode transform an internal.Object into a Blob struct
-func (c *Commit) Decode(o internal.Object) error {
+// Decode transform an core.Object into a Blob struct
+func (c *Commit) Decode(o core.Object) error {
c.Hash = o.Hash()
r := bufio.NewReader(o.Reader())
@@ -65,9 +67,9 @@ func (c *Commit) Decode(o internal.Object) error {
split := bytes.SplitN(line, []byte{' '}, 2)
switch string(split[0]) {
case "tree":
- c.tree = internal.NewHash(string(split[1]))
+ c.tree = core.NewHash(string(split[1]))
case "parent":
- c.parents = append(c.parents, internal.NewHash(string(split[1])))
+ c.parents = append(c.parents, core.NewHash(string(split[1])))
case "author":
c.Author.Decode(split[1])
case "committer":
@@ -86,7 +88,7 @@ func (c *Commit) Decode(o internal.Object) error {
func (c *Commit) String() string {
return fmt.Sprintf(
"%s %s\nAuthor: %s\nDate: %s\n",
- internal.CommitObject, c.Hash, c.Author.String(), c.Author.When,
+ core.CommitObject, c.Hash, c.Author.String(), c.Author.When,
)
}
@@ -109,16 +111,16 @@ func (i *CommitIter) Next() (*Commit, error) {
}
type iter struct {
- ch chan internal.Object
+ ch chan core.Object
r *Repository
}
func newIter(r *Repository) iter {
- ch := make(chan internal.Object, 1)
+ ch := make(chan core.Object, 1)
return iter{ch, r}
}
-func (i *iter) Add(o internal.Object) {
+func (i *iter) Add(o core.Object) {
i.ch <- o
}
diff --git a/common_test.go b/common_test.go
index 612afd1..d8647ff 100644
--- a/common_test.go
+++ b/common_test.go
@@ -9,7 +9,7 @@ import (
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v2/clients/common"
- "gopkg.in/src-d/go-git.v2/internal"
+ "gopkg.in/src-d/go-git.v2/core"
)
func Test(t *testing.T) { TestingT(t) }
@@ -21,7 +21,7 @@ func (s *MockGitUploadPackService) Connect(url common.Endpoint) error {
}
func (s *MockGitUploadPackService) Info() (*common.GitUploadPackInfo, error) {
- hash := internal.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
+ hash := core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
line := "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"
values, _ := url.ParseQuery(strings.Replace(line, " ", "&", -1))
@@ -29,7 +29,7 @@ func (s *MockGitUploadPackService) Info() (*common.GitUploadPackInfo, error) {
return &common.GitUploadPackInfo{
Capabilities: common.Capabilities(values),
Head: "refs/heads/master",
- Refs: map[string]internal.Hash{"refs/heads/master": hash},
+ Refs: map[string]core.Hash{"refs/heads/master": hash},
}, nil
}
diff --git a/core/errors.go b/core/errors.go
new file mode 100644
index 0000000..fd1133e
--- /dev/null
+++ b/core/errors.go
@@ -0,0 +1,35 @@
+package core
+
+import "fmt"
+
+type PermanentError struct {
+ err error
+}
+
+func NewPermanentError(err error) *PermanentError {
+ if err == nil {
+ return nil
+ }
+
+ return &PermanentError{err: err}
+}
+
+func (e *PermanentError) Error() string {
+ return fmt.Sprintf("permanent client error: %s", e.err.Error())
+}
+
+type UnexpectedError struct {
+ err error
+}
+
+func NewUnexpectedError(err error) *UnexpectedError {
+ if err == nil {
+ return nil
+ }
+
+ return &UnexpectedError{err: err}
+}
+
+func (e *UnexpectedError) Error() string {
+ return fmt.Sprintf("unexpected client error: %s", e.err.Error())
+}
diff --git a/internal/hash.go b/core/hash.go
index 0540db1..0b6f274 100644
--- a/internal/hash.go
+++ b/core/hash.go
@@ -1,4 +1,4 @@
-package internal
+package core
import (
"crypto/sha1"
diff --git a/internal/hash_test.go b/core/hash_test.go
index 063bd23..8c4ed67 100644
--- a/internal/hash_test.go
+++ b/core/hash_test.go
@@ -1,4 +1,4 @@
-package internal
+package core
import (
"testing"
diff --git a/internal/object.go b/core/object.go
index a30bc9d..4e8a587 100644
--- a/internal/object.go
+++ b/core/object.go
@@ -1,4 +1,4 @@
-package internal
+package core
import (
"bytes"
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)
diff --git a/objects.go b/objects.go
index 49c0e9e..351a022 100644
--- a/objects.go
+++ b/objects.go
@@ -6,19 +6,19 @@ import (
"strconv"
"time"
- "gopkg.in/src-d/go-git.v2/internal"
+ "gopkg.in/src-d/go-git.v2/core"
)
// Blob is used to store file data - it is generally a file.
type Blob struct {
- Hash internal.Hash
+ Hash core.Hash
Size int64
- obj internal.Object
+ obj core.Object
}
-// Decode transform an internal.Object into a Blob struct
-func (b *Blob) Decode(o internal.Object) error {
+// Decode transform an core.Object into a Blob struct
+func (b *Blob) Decode(o core.Object) error {
b.Hash = o.Hash()
b.Size = o.Size()
b.obj = o
diff --git a/objects_test.go b/objects_test.go
index 8c2959f..d2bd7db 100644
--- a/objects_test.go
+++ b/objects_test.go
@@ -5,7 +5,7 @@ import (
"time"
. "gopkg.in/check.v1"
- "gopkg.in/src-d/go-git.v2/internal"
+ "gopkg.in/src-d/go-git.v2/core"
)
type ObjectsSuite struct {
@@ -24,7 +24,7 @@ func (s *ObjectsSuite) SetUpTest(c *C) {
}
func (s *ObjectsSuite) TestNewCommit(c *C) {
- hash := internal.NewHash("a5b8b09e2f8fcb0bb99d3ccb0958157b40890d69")
+ hash := core.NewHash("a5b8b09e2f8fcb0bb99d3ccb0958157b40890d69")
commit, err := s.r.Commit(hash)
c.Assert(err, IsNil)
@@ -48,7 +48,7 @@ func (s *ObjectsSuite) TestNewCommit(c *C) {
}
func (s *ObjectsSuite) TestParseTree(c *C) {
- hash := internal.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")
+ hash := core.NewHash("a8d315b2b1c615d43042c3a62402b8a54288cf5c")
tree, err := s.r.Tree(hash)
c.Assert(err, IsNil)
@@ -71,8 +71,8 @@ func (s *ObjectsSuite) TestParseTree(c *C) {
}
func (s *ObjectsSuite) TestBlobHash(c *C) {
- o := &internal.RAWObject{}
- o.SetType(internal.BlobObject)
+ o := &core.RAWObject{}
+ o.SetType(core.BlobObject)
o.SetSize(3)
o.Writer().Write([]byte{'F', 'O', 'O'})
diff --git a/remote.go b/remote.go
index 1c74ce0..1d92ac6 100644
--- a/remote.go
+++ b/remote.go
@@ -6,7 +6,7 @@ import (
"gopkg.in/src-d/go-git.v2/clients"
"gopkg.in/src-d/go-git.v2/clients/common"
- "gopkg.in/src-d/go-git.v2/internal"
+ "gopkg.in/src-d/go-git.v2/core"
)
type Remote struct {
@@ -66,21 +66,21 @@ func (r *Remote) FetchDefaultBranch() (io.ReadCloser, error) {
}
return r.Fetch(&common.GitUploadPackRequest{
- Want: []internal.Hash{ref},
+ Want: []core.Hash{ref},
})
}
// Ref returns the Hash pointing the given refName
-func (r *Remote) Ref(refName string) (internal.Hash, error) {
+func (r *Remote) Ref(refName string) (core.Hash, error) {
ref, ok := r.upInfo.Refs[refName]
if !ok {
- return internal.NewHash(""), fmt.Errorf("unable to find ref %q", refName)
+ return core.NewHash(""), fmt.Errorf("unable to find ref %q", refName)
}
return ref, nil
}
// Refs returns the Hash pointing the given refName
-func (r *Remote) Refs() map[string]internal.Hash {
+func (r *Remote) Refs() map[string]core.Hash {
return r.upInfo.Refs
}
diff --git a/remote_test.go b/remote_test.go
index 6d8c2ff..6bfa139 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -1,8 +1,8 @@
package git
import (
+ "gopkg.in/src-d/go-git.v2/core"
"gopkg.in/src-d/go-git.v2/formats/packfile"
- "gopkg.in/src-d/go-git.v2/internal"
. "gopkg.in/check.v1"
)
@@ -49,7 +49,7 @@ func (s *SuiteRemote) TestFetchDefaultBranch(c *C) {
pr := packfile.NewReader(reader)
- storage := internal.NewRAWObjectStorage()
+ storage := core.NewRAWObjectStorage()
_, err = pr.Read(storage)
c.Assert(err, IsNil)
c.Assert(storage.Objects, HasLen, 28)
diff --git a/repository.go b/repository.go
index c732d0f..9bdccc0 100644
--- a/repository.go
+++ b/repository.go
@@ -5,8 +5,8 @@ import (
"fmt"
"gopkg.in/src-d/go-git.v2/clients/common"
+ "gopkg.in/src-d/go-git.v2/core"
"gopkg.in/src-d/go-git.v2/formats/packfile"
- "gopkg.in/src-d/go-git.v2/internal"
)
var (
@@ -19,7 +19,7 @@ const (
type Repository struct {
Remotes map[string]*Remote
- Storage *internal.RAWObjectStorage
+ Storage *core.RAWObjectStorage
}
// NewRepository creates a new repository setting remote as default remote
@@ -39,7 +39,7 @@ func NewRepository(url string) (*Repository, error) {
func NewPlainRepository() *Repository {
return &Repository{
Remotes: map[string]*Remote{},
- Storage: internal.NewRAWObjectStorage(),
+ Storage: core.NewRAWObjectStorage(),
}
}
@@ -59,7 +59,7 @@ func (r *Repository) Pull(remoteName, branch string) error {
}
reader, err := remote.Fetch(&common.GitUploadPackRequest{
- Want: []internal.Hash{ref},
+ Want: []core.Hash{ref},
})
pr := packfile.NewReader(reader)
@@ -73,7 +73,7 @@ func (r *Repository) Pull(remoteName, branch string) error {
}
// Commit return the commit with the given hash
-func (r *Repository) Commit(h internal.Hash) (*Commit, error) {
+func (r *Repository) Commit(h core.Hash) (*Commit, error) {
obj, ok := r.Storage.Get(h)
if !ok {
return nil, ObjectNotFoundErr
@@ -97,7 +97,7 @@ func (r *Repository) Commits() *CommitIter {
}
// Tree return the tree with the given hash
-func (r *Repository) Tree(h internal.Hash) (*Tree, error) {
+func (r *Repository) Tree(h core.Hash) (*Tree, error) {
obj, ok := r.Storage.Get(h)
if !ok {
return nil, ObjectNotFoundErr
diff --git a/repository_test.go b/repository_test.go
index d377478..7a480f1 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -2,7 +2,7 @@ package git
import (
. "gopkg.in/check.v1"
- "gopkg.in/src-d/go-git.v2/internal"
+ "gopkg.in/src-d/go-git.v2/core"
)
type SuiteRepository struct{}
@@ -24,7 +24,7 @@ func (s *SuiteRepository) TestCommit(c *C) {
c.Assert(err, IsNil)
c.Assert(r.Pull("origin", "refs/heads/master"), IsNil)
- hash := internal.NewHash("b8e471f58bcbca63b07bda20e428190409c2db47")
+ hash := core.NewHash("b8e471f58bcbca63b07bda20e428190409c2db47")
commit, err := r.Commit(hash)
c.Assert(err, IsNil)
diff --git a/tree.go b/tree.go
index 192c6a0..2dcc5af 100644
--- a/tree.go
+++ b/tree.go
@@ -7,14 +7,14 @@ import (
"path/filepath"
"strconv"
- "gopkg.in/src-d/go-git.v2/internal"
+ "gopkg.in/src-d/go-git.v2/core"
)
// Tree is basically like a directory - it references a bunch of other trees
// and/or blobs (i.e. files and sub-directories)
type Tree struct {
Entries []TreeEntry
- Hash internal.Hash
+ Hash core.Hash
r *Repository
}
@@ -23,7 +23,7 @@ type Tree struct {
type TreeEntry struct {
Name string
Mode os.FileMode
- Hash internal.Hash
+ Hash core.Hash
}
func (t *Tree) Files() chan *File {
@@ -40,7 +40,7 @@ func (t *Tree) Files() chan *File {
func (t *Tree) walkEntries(base string, ch chan *File) {
for _, entry := range t.Entries {
obj, _ := t.r.Storage.Get(entry.Hash)
- if obj.Type() == internal.TreeObject {
+ if obj.Type() == core.TreeObject {
tree := &Tree{r: t.r}
tree.Decode(obj)
tree.walkEntries(filepath.Join(base, entry.Name), ch)
@@ -54,8 +54,8 @@ func (t *Tree) walkEntries(base string, ch chan *File) {
}
}
-// Decode transform an internal.Object into a Tree struct
-func (t *Tree) Decode(o internal.Object) error {
+// Decode transform an core.Object into a Tree struct
+func (t *Tree) Decode(o core.Object) error {
t.Hash = o.Hash()
if o.Size() == 0 {
return nil
@@ -82,7 +82,7 @@ func (t *Tree) Decode(o internal.Object) error {
return err
}
- var hash internal.Hash
+ var hash core.Hash
_, err = r.Read(hash[:])
if err != nil && err != io.EOF {
return err