diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/refspec.go | 18 | ||||
-rw-r--r-- | config/refspec_test.go | 20 |
2 files changed, 19 insertions, 19 deletions
diff --git a/config/refspec.go b/config/refspec.go index 0f41c5a..fd0aa3d 100644 --- a/config/refspec.go +++ b/config/refspec.go @@ -3,7 +3,7 @@ package config import ( "strings" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) const ( @@ -57,8 +57,8 @@ func (s RefSpec) Src() string { return spec[start:end] } -// Match match the given core.ReferenceName against the source -func (s RefSpec) Match(n core.ReferenceName) bool { +// Match match the given plumbing.ReferenceName against the source +func (s RefSpec) Match(n plumbing.ReferenceName) bool { if !s.IsWildcard() { return s.matchExact(n) } @@ -71,11 +71,11 @@ func (s RefSpec) IsWildcard() bool { return strings.Index(string(s), refSpecWildcard) != -1 } -func (s RefSpec) matchExact(n core.ReferenceName) bool { +func (s RefSpec) matchExact(n plumbing.ReferenceName) bool { return s.Src() == n.String() } -func (s RefSpec) matchGlob(n core.ReferenceName) bool { +func (s RefSpec) matchGlob(n plumbing.ReferenceName) bool { src := s.Src() name := n.String() wildcard := strings.Index(src, refSpecWildcard) @@ -92,14 +92,14 @@ func (s RefSpec) matchGlob(n core.ReferenceName) bool { } // Dst returns the destination for the given remote reference -func (s RefSpec) Dst(n core.ReferenceName) core.ReferenceName { +func (s RefSpec) Dst(n plumbing.ReferenceName) plumbing.ReferenceName { spec := string(s) start := strings.Index(spec, refSpecSeparator) + 1 dst := spec[start:] src := s.Src() if !s.IsWildcard() { - return core.ReferenceName(dst) + return plumbing.ReferenceName(dst) } name := n.String() @@ -107,7 +107,7 @@ func (s RefSpec) Dst(n core.ReferenceName) core.ReferenceName { wd := strings.Index(dst, refSpecWildcard) match := name[ws : len(name)-(len(src)-(ws+1))] - return core.ReferenceName(dst[0:wd] + match + dst[wd+1:]) + return plumbing.ReferenceName(dst[0:wd] + match + dst[wd+1:]) } func (s RefSpec) String() string { @@ -115,7 +115,7 @@ func (s RefSpec) String() string { } // MatchAny returns true if any of the RefSpec match with the given ReferenceName -func MatchAny(l []RefSpec, n core.ReferenceName) bool { +func MatchAny(l []RefSpec, n plumbing.ReferenceName) bool { for _, r := range l { if r.Match(n) { return true diff --git a/config/refspec_test.go b/config/refspec_test.go index 632f5a4..f0d1a0e 100644 --- a/config/refspec_test.go +++ b/config/refspec_test.go @@ -4,7 +4,7 @@ import ( "testing" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/plumbing" ) type RefSpecSuite struct{} @@ -42,20 +42,20 @@ func (s *RefSpecSuite) TestRefSpecSrc(c *C) { func (s *RefSpecSuite) TestRefSpecMatch(c *C) { spec := RefSpec("refs/heads/master:refs/remotes/origin/master") - c.Assert(spec.Match(core.ReferenceName("refs/heads/foo")), Equals, false) - c.Assert(spec.Match(core.ReferenceName("refs/heads/master")), Equals, true) + c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/foo")), Equals, false) + c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/master")), Equals, true) } func (s *RefSpecSuite) TestRefSpecMatchBlob(c *C) { spec := RefSpec("refs/heads/*:refs/remotes/origin/*") - c.Assert(spec.Match(core.ReferenceName("refs/tag/foo")), Equals, false) - c.Assert(spec.Match(core.ReferenceName("refs/heads/foo")), Equals, true) + c.Assert(spec.Match(plumbing.ReferenceName("refs/tag/foo")), Equals, false) + c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/foo")), Equals, true) } func (s *RefSpecSuite) TestRefSpecDst(c *C) { spec := RefSpec("refs/heads/master:refs/remotes/origin/master") c.Assert( - spec.Dst(core.ReferenceName("refs/heads/master")).String(), Equals, + spec.Dst(plumbing.ReferenceName("refs/heads/master")).String(), Equals, "refs/remotes/origin/master", ) } @@ -63,7 +63,7 @@ func (s *RefSpecSuite) TestRefSpecDst(c *C) { func (s *RefSpecSuite) TestRefSpecDstBlob(c *C) { spec := RefSpec("refs/heads/*:refs/remotes/origin/*") c.Assert( - spec.Dst(core.ReferenceName("refs/heads/foo")).String(), Equals, + spec.Dst(plumbing.ReferenceName("refs/heads/foo")).String(), Equals, "refs/remotes/origin/foo", ) } @@ -73,7 +73,7 @@ func (s *RefSpecSuite) TestMatchAny(c *C) { "refs/heads/foo:refs/remotes/origin/bar", } - c.Assert(MatchAny(specs, core.ReferenceName("refs/heads/foo")), Equals, true) - c.Assert(MatchAny(specs, core.ReferenceName("refs/heads/bar")), Equals, true) - c.Assert(MatchAny(specs, core.ReferenceName("refs/heads/master")), Equals, false) + c.Assert(MatchAny(specs, plumbing.ReferenceName("refs/heads/foo")), Equals, true) + c.Assert(MatchAny(specs, plumbing.ReferenceName("refs/heads/bar")), Equals, true) + c.Assert(MatchAny(specs, plumbing.ReferenceName("refs/heads/master")), Equals, false) } |