mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Add user config to change the sort order of tags
This commit is contained in:
committed by
Jesse Duffield
parent
258eedb38c
commit
472288c81b
@ -44,6 +44,7 @@ gui:
|
|||||||
showRandomTip: true
|
showRandomTip: true
|
||||||
showCommandLog: true
|
showCommandLog: true
|
||||||
commandLogSize: 8
|
commandLogSize: 8
|
||||||
|
sortTagsDescending: false # sort order for tags
|
||||||
git:
|
git:
|
||||||
paging:
|
paging:
|
||||||
colorArg: always
|
colorArg: always
|
||||||
|
@ -46,11 +46,18 @@ func (c *GitCommand) GetTags() ([]*models.Tag, error) {
|
|||||||
// now lets sort our tags by name numerically
|
// now lets sort our tags by name numerically
|
||||||
re := regexp.MustCompile(semverRegex)
|
re := regexp.MustCompile(semverRegex)
|
||||||
|
|
||||||
|
sortAsc := !c.Config.GetUserConfig().Gui.SortTagsDescending
|
||||||
// the reason this is complicated is because we're both sorting alphabetically
|
// the reason this is complicated is because we're both sorting alphabetically
|
||||||
// and when we're dealing with semver strings
|
// and when we're dealing with semver strings
|
||||||
sort.Slice(tags, func(i, j int) bool {
|
sort.Slice(tags, func(i, j int) bool {
|
||||||
a := tags[i].Name
|
var a, b string
|
||||||
b := tags[j].Name
|
if sortAsc {
|
||||||
|
a = tags[i].Name
|
||||||
|
b = tags[j].Name
|
||||||
|
} else {
|
||||||
|
b = tags[i].Name
|
||||||
|
a = tags[j].Name
|
||||||
|
}
|
||||||
|
|
||||||
matchA := re.FindStringSubmatch(a)
|
matchA := re.FindStringSubmatch(a)
|
||||||
matchB := re.FindStringSubmatch(b)
|
matchB := re.FindStringSubmatch(b)
|
||||||
|
@ -39,6 +39,7 @@ type GuiConfig struct {
|
|||||||
ShowRandomTip bool `yaml:"showRandomTip"`
|
ShowRandomTip bool `yaml:"showRandomTip"`
|
||||||
ShowCommandLog bool `yaml:"showCommandLog"`
|
ShowCommandLog bool `yaml:"showCommandLog"`
|
||||||
CommandLogSize int `yaml:"commandLogSize"`
|
CommandLogSize int `yaml:"commandLogSize"`
|
||||||
|
SortTagsDescending bool `yaml:"sortTagsDescending"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ThemeConfig struct {
|
type ThemeConfig struct {
|
||||||
@ -307,6 +308,7 @@ func GetDefaultConfig() *UserConfig {
|
|||||||
ShowFileTree: false,
|
ShowFileTree: false,
|
||||||
ShowRandomTip: true,
|
ShowRandomTip: true,
|
||||||
CommandLogSize: 8,
|
CommandLogSize: 8,
|
||||||
|
SortTagsDescending: false,
|
||||||
},
|
},
|
||||||
Git: GitConfig{
|
Git: GitConfig{
|
||||||
Paging: PagingConfig{
|
Paging: PagingConfig{
|
||||||
|
Reference in New Issue
Block a user