Merge pull request #1235 from rhatdan/hooks

Report an warning when no stages are defined for a hook
This commit is contained in:
Mrunal Patel 2018-02-03 09:51:59 -08:00 committed by GitHub
commit b8d2482b26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,11 +54,15 @@ func readHook(hookPath string) (HookParams, error) {
return hook, errors.Wrapf(err, "invalid cmd regular expression %q defined in hook config %q", cmd, hookPath) return hook, errors.Wrapf(err, "invalid cmd regular expression %q defined in hook config %q", cmd, hookPath)
} }
} }
if len(hook.Stage) == 0 {
logrus.Warnf("No stage defined in hook config %q, hook will never run", hookPath)
} else {
for _, stage := range hook.Stage { for _, stage := range hook.Stage {
if !validStage[stage] { if !validStage[stage] {
return hook, errors.Wrapf(err, "unknown stage %q defined in hook config %q", stage, hookPath) return hook, errors.Wrapf(err, "unknown stage %q defined in hook config %q", stage, hookPath)
} }
} }
}
return hook, nil return hook, nil
} }