diff options
author | Robert Verst <robert@verst.eu> | 2021-05-19 19:14:32 +0200 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-06-05 10:56:46 +1000 |
commit | 472288c81b3ad48dc86e5a8538c11c7a18e6a604 (patch) | |
tree | 0b8ba32cc6d66ca1d4b31b894b97422e18bd67fc /pkg/commands/loading_tags.go | |
parent | 258eedb38c6e8692565d74a92e3590da477dea6b (diff) |
Add user config to change the sort order of tags
Diffstat (limited to 'pkg/commands/loading_tags.go')
-rw-r--r-- | pkg/commands/loading_tags.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pkg/commands/loading_tags.go b/pkg/commands/loading_tags.go index 9ed350fd5..21925f184 100644 --- a/pkg/commands/loading_tags.go +++ b/pkg/commands/loading_tags.go @@ -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) |