Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow extra hooks in local config #462

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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