Skip to content

Commit edf5c0c

Browse files
committed
Reverse the order of tags below git 2.0
1 parent 76e8cce commit edf5c0c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

repo_tag.go

Lines changed: 14 additions & 2 deletions
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)