Skip to content

Commit

Permalink
Merge pull request #8 from moltam/feature/order-tags-below-git2
Browse files Browse the repository at this point in the history
Reverse the order of tags below git 2.0
  • Loading branch information
unknwon committed Mar 21, 2016
2 parents 76e8cce + edf5c0c commit 59330e2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions repo_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ func (repo *Repository) GetTags() ([]string, error) {
if err != nil {
return nil, err
}
tags := strings.Split(stdout, "\n")
return tags[:len(tags)-1], nil

tags := strings.Split(strings.TrimSpace(stdout), "\n")

if version.Compare(gitVersion, "2.0.0", "<") {
version.Sort(tags)

// Reverse order
for i := 0; i < len(tags) / 2; i++ {
j := len(tags) - i - 1
tags[i], tags[j] = tags[j], tags[i]
}
}

return tags, nil
}

0 comments on commit 59330e2

Please sign in to comment.