mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Fix loading customCommands from per-repo config file
Any newly loaded custom command coming from the per-repo config file should add to the global ones (or override an existing one in the global one), rather than replace all global ones. We can achieve this by simply prepending the newly loaded commands to the existing ones. We don't have to take care of removing duplicate key assignments; it is already possible to add two custom commands with the same key to the global config file, the first one wins.
This commit is contained in:
parent
283ed29f10
commit
30f43a245b
2 changed files with 4 additions and 3 deletions
|
@ -196,10 +196,14 @@ func loadUserConfig(configFiles []*ConfigFile, base *UserConfig) (*UserConfig, e
|
|||
return nil, err
|
||||
}
|
||||
|
||||
existingCustomCommands := base.CustomCommands
|
||||
|
||||
if err := yaml.Unmarshal(content, base); err != nil {
|
||||
return nil, fmt.Errorf("The config at `%s` couldn't be parsed, please inspect it before opening up an issue.\n%w", path, err)
|
||||
}
|
||||
|
||||
base.CustomCommands = append(base.CustomCommands, existingCustomCommands...)
|
||||
|
||||
if err := base.Validate(); err != nil {
|
||||
return nil, fmt.Errorf("The config at `%s` has a validation error.\n%w", path, err)
|
||||
}
|
||||
|
|
|
@ -49,10 +49,7 @@ customCommands:
|
|||
t.Views().Status().Content(Contains("other → master"))
|
||||
|
||||
t.GlobalPress("X")
|
||||
/* EXPECTED:
|
||||
t.FileSystem().FileContent("../other/file.txt", Equals("global X"))
|
||||
ACTUAL: */
|
||||
t.FileSystem().PathNotPresent("../other/file.txt")
|
||||
|
||||
t.GlobalPress("Y")
|
||||
t.FileSystem().FileContent("../other/file.txt", Equals("local Y"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue