diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-10-26 23:45:37 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-10-26 23:45:37 +0200 |
commit | 0c3bc0c8b3eabe16e927475f26044ca9aaa50351 (patch) | |
tree | 219d36a5cd5b13af6c0231176ddca9b728a308b2 /remote.go | |
parent | c66f495b35b12c6827507b9933b39a10fa94379b (diff) | |
download | go-git-0c3bc0c8b3eabe16e927475f26044ca9aaa50351.tar.gz |
remote, fix copy tag reference on fetch
Diffstat (limited to 'remote.go')
-rw-r--r-- | remote.go | 31 |
1 files changed, 28 insertions, 3 deletions
@@ -190,8 +190,8 @@ func (r *Remote) updateObjectStorage(reader io.Reader) error { } func (r *Remote) updateLocalReferenceStorage(specs []config.RefSpec, refs []*core.Reference) error { - for _, ref := range refs { - for _, spec := range specs { + for _, spec := range specs { + for _, ref := range refs { if !spec.Match(ref.Name()) { continue } @@ -208,7 +208,32 @@ func (r *Remote) updateLocalReferenceStorage(specs []config.RefSpec, refs []*cor } } - return nil + return r.buildFetchedTags() +} + +func (r *Remote) buildFetchedTags() error { + iter, err := r.Refs() + if err != nil { + return err + } + + os := r.s.ObjectStorage() + return iter.ForEach(func(ref *core.Reference) error { + if !ref.IsTag() { + return nil + } + + _, err := os.Get(core.CommitObject, ref.Hash()) + if err == core.ErrObjectNotFound { + return nil + } + + if err != nil { + return err + } + + return r.s.ReferenceStorage().Set(ref) + }) } // Head returns the Reference of the HEAD |