diff --git a/internal/lefthook/lefthook.go b/internal/lefthook/lefthook.go index 236efc66..5adcb142 100644 --- a/internal/lefthook/lefthook.go +++ b/internal/lefthook/lefthook.go @@ -3,6 +3,7 @@ package lefthook import ( "bufio" "fmt" + "os" "path/filepath" "regexp" @@ -13,7 +14,10 @@ import ( "github.com/evilmartians/lefthook/internal/templates" ) -const hookFileMode = 0o755 +const ( + hookFileMode = 0o755 + envVerbose = "LEFTHOOK_VERBOSE" // keep all output +) var lefthookContentRegexp = regexp.MustCompile("LEFTHOOK") @@ -35,6 +39,10 @@ type Lefthook struct { // New returns an instance of Lefthook. func initialize(opts *Options) (*Lefthook, error) { + if os.Getenv(envVerbose) == "1" || os.Getenv(envVerbose) == "true" { + opts.Verbose = true + } + if opts.Verbose { log.SetLevel(log.DebugLevel) } diff --git a/internal/lefthook/run.go b/internal/lefthook/run.go index e1844c95..9e68c77d 100644 --- a/internal/lefthook/run.go +++ b/internal/lefthook/run.go @@ -15,9 +15,8 @@ import ( ) const ( - envEnabled = "LEFTHOOK" // "0", "false" - envSkipOutput = "LEFTHOOK_QUIET" // "meta,success,failure,summary,skips,execution,execution_out,execution_info" - envVerbose = "LEFTHOOK_VERBOSE" // keep all output + envEnabled = "LEFTHOOK" // "0", "false" + envSkipOutput = "LEFTHOOK_QUIET" // "meta,success,failure,summary,skips,execution,execution_out,execution_info" ) type RunArgs struct { @@ -39,7 +38,7 @@ func (l *Lefthook) Run(hookName string, args RunArgs, gitArgs []string) error { } var verbose bool - if l.Verbose || os.Getenv(envVerbose) == "1" || os.Getenv(envVerbose) == "true" { + if l.Verbose { log.SetLevel(log.DebugLevel) verbose = true }