From 055254d1792ce8e24573e4405f4355ae35df0622 Mon Sep 17 00:00:00 2001 From: Valentine Kiselev Date: Wed, 16 Nov 2022 11:24:10 +0300 Subject: [PATCH] fix: Print prepare-commit-msg hook if it exists in config (#368) --- internal/lefthook/run.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/lefthook/run.go b/internal/lefthook/run.go index d24563f0..b243146e 100644 --- a/internal/lefthook/run.go +++ b/internal/lefthook/run.go @@ -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 @@ -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, ",")...) }