diff options
author | Sunny <me@darkowlzz.space> | 2017-10-02 14:42:08 +0530 |
---|---|---|
committer | Sunny <me@darkowlzz.space> | 2017-10-02 14:42:08 +0530 |
commit | 7172e04fe7e000d8826f0402dd7f70d8b3d55072 (patch) | |
tree | 0af4b7ed70ae40812f855d9c556d0171579761e6 /remote.go | |
parent | f9879dd043f84936a1f8acb8a53b74332a7ae135 (diff) | |
download | go-git-7172e04fe7e000d8826f0402dd7f70d8b3d55072.tar.gz |
remote: add support for ls-remote
Diffstat (limited to 'remote.go')
-rw-r--r-- | remote.go | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -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 { |