Skip to content

Commit

Permalink
Merge pull request #28 from Masterminds/cleanup-tags-from-commit
Browse files Browse the repository at this point in the history
Reducing calls to git to retrieve tags
  • Loading branch information
mattfarina committed Apr 18, 2016
2 parents 591ce24 + b2f5815 commit e24dbe4
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions git.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,8 @@ func (s *GitRepo) TagsFromCommit(id string) ([]string, error) {
// This is imperfect and a better method would be great.

var re []string
// Get the one we think is right first. This only returns a single tag.
out, err := s.RunFromDir("git", "describe", "--tags", "--exact-match", id)
if err == nil {
// If there is no tag describing the commit it returns an error.
re = append(re, strings.TrimSpace(string(out)))
}

out, err = s.RunFromDir("git", "show-ref", "-d")
out, err := s.RunFromDir("git", "show-ref", "-d")
if err != nil {
return []string{}, NewLocalError("Unable to retrieve tags", err, string(out))
}
Expand All @@ -294,19 +288,8 @@ func (s *GitRepo) TagsFromCommit(id string) ([]string, error) {
}
}
tags := s.referenceList(strings.Join(list, "\n"), `(?m-s)(?:tags)/(\S+)$`)
var found bool
for _, t := range tags {
found = false
for _, v := range re {
if v == t {
found = true
break
}
}

if !found {
re = append(re, t)
}
re = append(re, t)
}

return re, nil
Expand Down

0 comments on commit e24dbe4

Please sign in to comment.