1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-28 16:02:01 +03:00

Add user config to change the sort order of tags

This commit is contained in:
Robert Verst
2021-05-19 19:14:32 +02:00
committed by Jesse Duffield
parent 258eedb38c
commit 472288c81b
3 changed files with 12 additions and 2 deletions

View File

@ -46,11 +46,18 @@ func (c *GitCommand) GetTags() ([]*models.Tag, error) {
// now lets sort our tags by name numerically
re := regexp.MustCompile(semverRegex)
sortAsc := !c.Config.GetUserConfig().Gui.SortTagsDescending
// the reason this is complicated is because we're both sorting alphabetically
// and when we're dealing with semver strings
sort.Slice(tags, func(i, j int) bool {
a := tags[i].Name
b := tags[j].Name
var a, b string
if sortAsc {
a = tags[i].Name
b = tags[j].Name
} else {
b = tags[i].Name
a = tags[j].Name
}
matchA := re.FindStringSubmatch(a)
matchB := re.FindStringSubmatch(b)