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 /clients/common | |
parent | fe1fc1aa7dca3e0f6e54ab17f0acfa45f269e58c (diff) | |
download | go-git-c6349552c1c54ea114b92ae23fc840f68f6551f4.tar.gz |
internal -> core
Diffstat (limited to 'clients/common')
-rw-r--r-- | clients/common/common.go | 50 | ||||
-rw-r--r-- | clients/common/common_test.go | 16 |
2 files changed, 17 insertions, 49 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"), }, } |