aboutsummaryrefslogtreecommitdiffstats
path: root/clients
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2015-10-31 01:14:03 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2015-10-31 01:14:03 +0100
commitc6349552c1c54ea114b92ae23fc840f68f6551f4 (patch)
tree6fbaf514ae9caf8241a0b9dfc3709d60942876c5 /clients
parentfe1fc1aa7dca3e0f6e54ab17f0acfa45f269e58c (diff)
downloadgo-git-c6349552c1c54ea114b92ae23fc840f68f6551f4.tar.gz
internal -> core
Diffstat (limited to 'clients')
-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
5 files changed, 27 insertions, 57 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"),
},
})