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 /remote_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 'remote_test.go')
-rw-r--r-- | remote_test.go | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/remote_test.go b/remote_test.go index 6766514..0fc3449 100644 --- a/remote_test.go +++ b/remote_test.go @@ -20,8 +20,8 @@ import ( "github.com/go-git/go-git/v5/storage/memory" "github.com/go-git/go-billy/v5/osfs" - . "gopkg.in/check.v1" fixtures "github.com/go-git/go-git-fixtures/v4" + . "gopkg.in/check.v1" ) type RemoteSuite struct { @@ -71,6 +71,35 @@ func (s *RemoteSuite) TestFetchWildcard(c *C) { }) } +func (s *RemoteSuite) TestFetchExactSHA1(c *C) { + r := NewRemote(memory.NewStorage(), &config.RemoteConfig{ + URLs: []string{"https://github.com/git-fixtures/basic.git"}, + }) + + s.testFetch(c, r, &FetchOptions{ + RefSpecs: []config.RefSpec{ + config.RefSpec("35e85108805c84807bc66a02d91535e1e24b38b9:refs/heads/foo"), + }, + }, []*plumbing.Reference{ + plumbing.NewReferenceFromStrings("refs/heads/foo", "35e85108805c84807bc66a02d91535e1e24b38b9"), + }) +} + +func (s *RemoteSuite) TestFetchExactSHA1_NotSoported(c *C) { + r := NewRemote(memory.NewStorage(), &config.RemoteConfig{ + URLs: []string{s.GetBasicLocalRepositoryURL()}, + }) + + err := r.Fetch(&FetchOptions{ + RefSpecs: []config.RefSpec{ + config.RefSpec("35e85108805c84807bc66a02d91535e1e24b38b9:refs/heads/foo"), + }, + }) + + c.Assert(err, Equals, ErrExactSHA1NotSupported) + +} + func (s *RemoteSuite) TestFetchWildcardTags(c *C) { r := NewRemote(memory.NewStorage(), &config.RemoteConfig{ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())}, |