Skip to content

Commit 59330e2

Browse files
committed
Merge pull request #8 from moltam/feature/order-tags-below-git2
Reverse the order of tags below git 2.0
2 parents 76e8cce + edf5c0c commit 59330e2

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

repo_tag.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ func (repo *Repository) GetTags() ([]string, error) {
102102
if err != nil {
103103
return nil, err
104104
}
105-
tags := strings.Split(stdout, "\n")
106-
return tags[:len(tags)-1], nil
105+
106+
tags := strings.Split(strings.TrimSpace(stdout), "\n")
107+
108+
if version.Compare(gitVersion, "2.0.0", "<") {
109+
version.Sort(tags)
110+
111+
// Reverse order
112+
for i := 0; i < len(tags) / 2; i++ {
113+
j := len(tags) - i - 1
114+
tags[i], tags[j] = tags[j], tags[i]
115+
}
116+
}
117+
118+
return tags, nil
107119
}

0 commit comments

Comments
 (0)