func (r *Repository) Tags() ([]*vcs.Tag, error) { r.editLock.RLock() defer r.editLock.RUnlock() refs, err := r.u.NewReferenceIterator() if err != nil { return nil, err } var ts []*vcs.Tag for { ref, err := refs.Next() if isErrIterOver(err) { break } if err != nil { return nil, err } if ref.IsTag() { ts = append(ts, &vcs.Tag{Name: ref.Shorthand(), CommitID: vcs.CommitID(ref.Target().String())}) } } sort.Sort(vcs.Tags(ts)) return ts, nil }
func (r *Repository) Tags() ([]*vcs.Tag, error) { ts := make([]*vcs.Tag, len(r.allTags.IdByName)) i := 0 for name, id := range r.allTags.IdByName { ts[i] = &vcs.Tag{Name: name, CommitID: vcs.CommitID(id)} i++ } sort.Sort(vcs.Tags(ts)) return ts, nil }