diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2020-05-11 00:28:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-11 00:28:21 +0200 |
commit | 568154cab87659b31c751678c7f7dc93fedf60af (patch) | |
tree | 233f993126f9346b06979202042bd5d95ba70bf2 /config/refspec_test.go | |
parent | e4166c560bfa0bcdadd3197ad00365b4f1c027fb (diff) | |
parent | 8ecd388ae101a0dd88b78dc47ebfef9fe51699df (diff) | |
download | go-git-568154cab87659b31c751678c7f7dc93fedf60af.tar.gz |
Merge pull request #58 from go-git/exact-sha1
Remote.Fetch: support exact SHA1 refspecs
Diffstat (limited to 'config/refspec_test.go')
-rw-r--r-- | config/refspec_test.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/config/refspec_test.go b/config/refspec_test.go index b9c43b2..3be7573 100644 --- a/config/refspec_test.go +++ b/config/refspec_test.go @@ -3,8 +3,8 @@ package config import ( "testing" - . "gopkg.in/check.v1" "github.com/go-git/go-git/v5/plumbing" + . "gopkg.in/check.v1" ) type RefSpecSuite struct{} @@ -37,6 +37,12 @@ func (s *RefSpecSuite) TestRefSpecIsValid(c *C) { spec = RefSpec("refs/heads:") c.Assert(spec.Validate(), Equals, ErrRefSpecMalformedSeparator) + + spec = RefSpec("12039e008f9a4e3394f3f94f8ea897785cb09448:refs/heads/foo") + c.Assert(spec.Validate(), Equals, nil) + + spec = RefSpec("12039e008f9a4e3394f3f94f8ea897785cb09448:refs/heads/*") + c.Assert(spec.Validate(), Equals, ErrRefSpecMalformedWildcard) } func (s *RefSpecSuite) TestRefSpecIsForceUpdate(c *C) { @@ -58,6 +64,14 @@ func (s *RefSpecSuite) TestRefSpecIsDelete(c *C) { c.Assert(spec.IsDelete(), Equals, false) } +func (s *RefSpecSuite) TestRefSpecIsExactSHA1(c *C) { + spec := RefSpec("foo:refs/heads/master") + c.Assert(spec.IsExactSHA1(), Equals, false) + + spec = RefSpec("12039e008f9a4e3394f3f94f8ea897785cb09448:refs/heads/foo") + c.Assert(spec.IsExactSHA1(), Equals, true) +} + func (s *RefSpecSuite) TestRefSpecSrc(c *C) { spec := RefSpec("refs/heads/*:refs/remotes/origin/*") c.Assert(spec.Src(), Equals, "refs/heads/*") |