aboutsummaryrefslogtreecommitdiffstats
path: root/remote_test.go
diff options
context:
space:
mode:
authorSunny <me@darkowlzz.space>2017-10-02 14:42:08 +0530
committerSunny <me@darkowlzz.space>2017-10-02 14:42:08 +0530
commit7172e04fe7e000d8826f0402dd7f70d8b3d55072 (patch)
tree0af4b7ed70ae40812f855d9c556d0171579761e6 /remote_test.go
parentf9879dd043f84936a1f8acb8a53b74332a7ae135 (diff)
downloadgo-git-7172e04fe7e000d8826f0402dd7f70d8b3d55072.tar.gz
remote: add support for ls-remote
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/remote_test.go b/remote_test.go
index 10f6708..4bb2037 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -11,6 +11,7 @@ import (
"gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
+ "gopkg.in/src-d/go-git.v4/plumbing/transport"
"gopkg.in/src-d/go-git.v4/storage"
"gopkg.in/src-d/go-git.v4/storage/filesystem"
"gopkg.in/src-d/go-git.v4/storage/memory"
@@ -642,3 +643,41 @@ func (s *RemoteSuite) TestGetHaves(c *C) {
c.Assert(err, IsNil)
c.Assert(l, HasLen, 2)
}
+
+func (s *RemoteSuite) TestLSRemote(c *C) {
+ url := c.MkDir()
+ server, err := PlainInit(url, true)
+ c.Assert(err, IsNil)
+
+ srcFs := fixtures.Basic().One().DotGit()
+ sto, err := filesystem.NewStorage(srcFs)
+ c.Assert(err, IsNil)
+
+ remote := newRemote(sto, &config.RemoteConfig{
+ Name: DefaultRemoteName,
+ URLs: []string{url},
+ })
+
+ rs := config.RefSpec("refs/heads/*:refs/heads/*")
+ err = remote.Push(&PushOptions{
+ RefSpecs: []config.RefSpec{rs},
+ })
+ c.Assert(err, IsNil)
+
+ // Perform ls-remote.
+ var authMethod transport.AuthMethod
+ refs, err := remote.LSRemote(authMethod)
+ c.Assert(err, IsNil)
+
+ // Create a map of remote name and their hash.
+ refsMap := map[string]string{}
+ for _, rf := range refs {
+ // Skip the symbolically linked HEAD.
+ if string(rf.Name()) == "HEAD" {
+ continue
+ }
+ refsMap[string(rf.Name())] = rf.Hash().String()
+ }
+
+ AssertReferences(c, server, refsMap)
+}