Skip to content

Commit

Permalink
fix: Print prepare-commit-msg hook if it exists in config (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox authored Nov 16, 2022
1 parent 2a376a7 commit 055254d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/lefthook/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ func (l *Lefthook) Run(hookName string, gitArgs []string) error {
return nil
}

var verbose bool
if l.Verbose || os.Getenv(envVerbose) == "1" || os.Getenv(envVerbose) == "true" {
log.SetLevel(log.DebugLevel)
} else {
if hookName == config.GhostHookName {
log.SetLevel(log.WarnLevel)
}
verbose = true
}

// Load config
Expand All @@ -51,6 +49,14 @@ func (l *Lefthook) Run(hookName string, gitArgs []string) error {
return err
}

// Suppress prepare-commit-msg output if the hook doesn't exists in config.
// prepare-commit-msg hook is used for seemless synchronization of hooks with config.
// See: internal/lefthook/install.go
_, ok := cfg.Hooks[hookName]
if hookName == config.GhostHookName && !ok && !verbose {
log.SetLevel(log.WarnLevel)
}

if tags := os.Getenv(envSkipOutput); tags != "" {
cfg.SkipOutput = append(cfg.SkipOutput, strings.Split(tags, ",")...)
}
Expand Down

0 comments on commit 055254d

Please sign in to comment.