From 3575bb98594c4bb1fa5050fc3b8ae10e82b12fa2 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 8 Jul 2025 12:22:16 +0200 Subject: [PATCH] Add enum validation for Git.Log.Order and Git.Log.ShowGraph --- pkg/config/user_config_validation.go | 8 +++++++ pkg/config/user_config_validation_test.go | 29 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/pkg/config/user_config_validation.go b/pkg/config/user_config_validation.go index 5d43c4a28..fc504fe32 100644 --- a/pkg/config/user_config_validation.go +++ b/pkg/config/user_config_validation.go @@ -31,6 +31,14 @@ func (config *UserConfig) Validate() error { []string{"date", "alphabetical"}); err != nil { return err } + if err := validateEnum("git.log.order", config.Git.Log.Order, + []string{"date-order", "author-date-order", "topo-order", "default"}); err != nil { + return err + } + if err := validateEnum("git.log.showGraph", config.Git.Log.ShowGraph, + []string{"always", "never", "when-maximised"}); err != nil { + return err + } if err := validateKeybindings(config.Keybinding); err != nil { return err } diff --git a/pkg/config/user_config_validation_test.go b/pkg/config/user_config_validation_test.go index 67ff16991..fcbfe1139 100644 --- a/pkg/config/user_config_validation_test.go +++ b/pkg/config/user_config_validation_test.go @@ -82,6 +82,35 @@ func TestUserConfigValidate_enums(t *testing.T) { {value: "invalid_value", valid: false}, }, }, + { + name: "Git.Log.Order", + setup: func(config *UserConfig, value string) { + config.Git.Log.Order = value + }, + testCases: []testCase{ + {value: "date-order", valid: true}, + {value: "author-date-order", valid: true}, + {value: "topo-order", valid: true}, + {value: "default", valid: true}, + + {value: "", valid: false}, + {value: "invalid_value", valid: false}, + }, + }, + { + name: "Git.Log.ShowGraph", + setup: func(config *UserConfig, value string) { + config.Git.Log.ShowGraph = value + }, + testCases: []testCase{ + {value: "always", valid: true}, + {value: "never", valid: true}, + {value: "when-maximised", valid: true}, + + {value: "", valid: false}, + {value: "invalid_value", valid: false}, + }, + }, { name: "Keybindings", setup: func(config *UserConfig, value string) {