mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-01 13:17:53 +02:00
Add user config to change the sort order of tags
This commit is contained in:
parent
258eedb38c
commit
472288c81b
@ -44,6 +44,7 @@ gui:
|
||||
showRandomTip: true
|
||||
showCommandLog: true
|
||||
commandLogSize: 8
|
||||
sortTagsDescending: false # sort order for tags
|
||||
git:
|
||||
paging:
|
||||
colorArg: always
|
||||
|
@ -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)
|
||||
|
@ -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{
|
||||
|
Loading…
x
Reference in New Issue
Block a user