From 9ad9412a8cd30bae18a9a98a0de2f3d3495314a8 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Thu, 12 Feb 2026 13:33:30 +0000 Subject: [PATCH] refactor: dynamically load all [DEFAULT] section aliases Removed hardcoded alias handling (unregister, git_gc) in favor of dynamically loading all key-value pairs from the [DEFAULT] section into the Aliases map. This allows mrconfig files to define custom aliases without code changes. - Simplified switch statement in LoadMRConfig - Updated function documentation - All tests passing --- parse/myrepos.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/parse/myrepos.go b/parse/myrepos.go index 3f8b462..46392a0 100644 --- a/parse/myrepos.go +++ b/parse/myrepos.go @@ -44,8 +44,7 @@ func (m MRConfig) ToMGConfig() MGConfig { } // LoadMRConfig loads the mrconfig file from the user's home directory -// and returns a MRConfig struct -// TODO: load aliases into map instead of hardcoded Unregister prop +// and returns a MRConfig struct with all repos and aliases from the [DEFAULT] section func LoadMRConfig() (MRConfig, error) { home, err := os.UserHomeDir() if err != nil { @@ -107,16 +106,8 @@ func LoadMRConfig() (MRConfig, error) { config.Repos[length].Remote = split[1] case "default": - - // TODO load text into Aliases map instead of hardcoded Unregister prop - switch split[0] { - case "unregister": - config.Aliases["unregister"] = split[1] - case "git_gc": - config.Aliases["gc"] = split[1] - default: - return MRConfig{}, fmt.Errorf("unexpected argument on line %d: %s", n, line) - } + // Load all DEFAULT section aliases into the map + config.Aliases[split[0]] = split[1] } } return config, nil