aboutsummaryrefslogtreecommitdiffstats
path: root/remote_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2020-05-11 00:17:29 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2020-05-11 00:17:29 +0200
commit8ecd388ae101a0dd88b78dc47ebfef9fe51699df (patch)
treee5a774f9b86c4c70bfcc20a0e65e652c85c3274e /remote_test.go
parent21f106e6647ce70d1d40df65cd85e2e86264d2f0 (diff)
downloadgo-git-8ecd388ae101a0dd88b78dc47ebfef9fe51699df.tar.gz
Remote.Fetch: support exact SHA1 refspecs
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go31
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())},