summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Verst <robert@verst.eu>2021-05-19 19:14:32 +0200
committerJesse Duffield <jessedduffield@gmail.com>2021-06-05 10:56:46 +1000
commit472288c81b3ad48dc86e5a8538c11c7a18e6a604 (patch)
tree0b8ba32cc6d66ca1d4b31b894b97422e18bd67fc
parent258eedb38c6e8692565d74a92e3590da477dea6b (diff)
Add user config to change the sort order of tags
-rw-r--r--docs/Config.md1
-rw-r--r--pkg/commands/loading_tags.go11
-rw-r--r--pkg/config/user_config.go2
3 files changed, 12 insertions, 2 deletions
diff --git a/docs/Config.md b/docs/Config.md
index c37747dbe..c322f2e87 100644
--- a/docs/Config.md
+++ b/docs/Config.md
@@ -44,6 +44,7 @@ gui:
showRandomTip: true
showCommandLog: true
commandLogSize: 8
+ sortTagsDescending: false # sort order for tags
git:
paging:
colorArg: always
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)
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go
index cf193011b..528830874 100644
--- a/pkg/config/user_config.go
+++ b/pkg/config/user_config.go
@@ -39,6 +39,7 @@ type GuiConfig struct {
ShowRandomTip bool `yaml:"showRandomTip"`
ShowCommandLog bool `yaml:"showCommandLog"`
CommandLogSize int `yaml:"commandLogSize"`
+ SortTagsDescending bool `yaml:"sortTagsDescending"`
}
type ThemeConfig struct {
@@ -307,6 +308,7 @@ func GetDefaultConfig() *UserConfig {
ShowFileTree: false,
ShowRandomTip: true,
CommandLogSize: 8,
+ SortTagsDescending: false,
},
Git: GitConfig{
Paging: PagingConfig{