aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-10-04 16:56:36 +0200
committerGitHub <noreply@github.com>2017-10-04 16:56:36 +0200
commita99c1291da1bf5c4ae8fada815231922f106bb70 (patch)
tree30af59374899c3537e1d257a65f9ab8f5733c73d /remote.go
parent30a99a264355ff1125c5464ad72965e927b1baea (diff)
parentb8eac90c420e14ebbabbb15523d024a4064e12ef (diff)
downloadgo-git-a99c1291da1bf5c4ae8fada815231922f106bb70.tar.gz
Merge pull request #609 from darkowlzz/ls-remote
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 f6a6a50..7cf4b65 100644
--- a/remote.go
+++ b/remote.go
@@ -759,6 +759,39 @@ func (r *Remote) buildFetchedTags(refs memory.ReferenceStorage) (updated bool, e
return
}
+// List the references on the remote repository.
+func (r *Remote) List(o *ListOptions) ([]*plumbing.Reference, error) {
+ s, err := newUploadPackSession(r.c.URLs[0], o.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 {