aboutsummaryrefslogtreecommitdiffstats
path: root/remote.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.go
parentf9879dd043f84936a1f8acb8a53b74332a7ae135 (diff)
downloadgo-git-7172e04fe7e000d8826f0402dd7f70d8b3d55072.tar.gz
remote: add support for ls-remote
Diffstat (limited to 'remote.go')
-rw-r--r--remote.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/remote.go b/remote.go
index 3e24763..c297e8e 100644
--- a/remote.go
+++ b/remote.go
@@ -728,6 +728,39 @@ func (r *Remote) buildFetchedTags(refs memory.ReferenceStorage) (updated bool, e
return
}
+// LSRemote performs ls-remote on the remote.
+func (r *Remote) LSRemote(auth transport.AuthMethod) ([]*plumbing.Reference, error) {
+ s, err := newUploadPackSession(r.c.URLs[0], auth)
+ if err != nil {
+ return nil, err
+ }
+
+ defer ioutil.CheckClose(s, &err)
+
+ ar, err := s.AdvertisedReferences()
+ if err != nil {
+ return nil, err
+ }
+
+ allRefs, err := ar.AllReferences()
+ if err != nil {
+ return nil, err
+ }
+
+ refs, err := allRefs.IterReferences()
+ if err != nil {
+ return nil, err
+ }
+
+ var resultRefs []*plumbing.Reference
+ refs.ForEach(func(ref *plumbing.Reference) error {
+ resultRefs = append(resultRefs, ref)
+ return nil
+ })
+
+ return resultRefs, nil
+}
+
func objectsToPush(commands []*packp.Command) ([]plumbing.Hash, error) {
var objects []plumbing.Hash
for _, cmd := range commands {