Skip to content

Commit

Permalink
Allow extra hooks also in local config
Browse files Browse the repository at this point in the history
  • Loading branch information
fabn committed Apr 3, 2023
1 parent da27fa5 commit cf4abe0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ func unmarshalConfigs(base, extra *viper.Viper, c *Config) error {

// For extra non-git hooks.
// This behavior may be deprecated in next versions.
for _, maybeHook := range base.AllKeys() {
// Notice that with append we're allowing extra hooks to be added in local config
for _, maybeHook := range append(base.AllKeys(), extra.AllKeys()...) {
if !hookKeyRegexp.MatchString(maybeHook) {
continue
}
Expand Down
37 changes: 37 additions & 0 deletions internal/config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,43 @@ tests:
tests:
run: go test ./...
lints:
scripts:
"linter.sh":
runner: bash
`,
result: &Config{
SourceDir: DefaultSourceDir,
SourceDirLocal: DefaultSourceDirLocal,
Colors: DefaultColorsEnabled,
Hooks: map[string]*Hook{
"tests": {
Parallel: false,
Commands: map[string]*Command{
"tests": {
Run: "go test ./...",
},
},
},
"lints": {
Scripts: map[string]*Script{
"linter.sh": {
Runner: "bash",
},
},
},
},
},
},
{
name: "with extra hooks only in local config",
global: `
tests:
commands:
tests:
run: go test ./...
`,
local: `
lints:
scripts:
"linter.sh":
Expand Down

0 comments on commit cf4abe0

Please sign in to comment.