From 27aca376331daaebb0bb08ad500176d9f4e48647 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Thu, 13 Jul 2023 18:47:07 -0700 Subject: [PATCH 1/4] refactor: Simplify printing of `execLog` --- internal/lefthook/runner/runner.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/lefthook/runner/runner.go b/internal/lefthook/runner/runner.go index 81d42388..ad0a530f 100644 --- a/internal/lefthook/runner/runner.go +++ b/internal/lefthook/runner/runner.go @@ -485,12 +485,12 @@ func (r *Runner) logExecute(name string, err error, out io.Reader) { execLog = fmt.Sprint(log.Cyan("\n EXECUTE > "), log.Bold(name)) } + log.Info(execLog) + if err == nil && r.SkipSettings.SkipExecutionOutput() { - log.Info(execLog) return } - log.Info(execLog) if out != nil { log.Info(out) } From c972c23a06d050b05ef218022e23b0bc913ea66f Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Thu, 13 Jul 2023 18:49:00 -0700 Subject: [PATCH 2/4] fix: Do not print extra newlines if `execution_info` output is hidden --- internal/lefthook/runner/runner.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/lefthook/runner/runner.go b/internal/lefthook/runner/runner.go index ad0a530f..92f67d87 100644 --- a/internal/lefthook/runner/runner.go +++ b/internal/lefthook/runner/runner.go @@ -478,14 +478,16 @@ func (r *Runner) logExecute(name string, err error, out io.Reader) { var execLog string switch { case r.SkipSettings.SkipExecutionInfo(): - execLog = "\n" + execLog = "" case err != nil: execLog = fmt.Sprint(log.Red("\n EXECUTE > "), log.Bold(name)) default: execLog = fmt.Sprint(log.Cyan("\n EXECUTE > "), log.Bold(name)) } - log.Info(execLog) + if execLog != "" { + log.Info(execLog) + } if err == nil && r.SkipSettings.SkipExecutionOutput() { return From d723973f5aec65c64da50a3abedd7a19c3b22a5a Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Mon, 17 Jul 2023 21:57:05 -0700 Subject: [PATCH 3/4] Move check for execution skipping --- internal/lefthook/runner/runner.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/lefthook/runner/runner.go b/internal/lefthook/runner/runner.go index 92f67d87..c1b9ff22 100644 --- a/internal/lefthook/runner/runner.go +++ b/internal/lefthook/runner/runner.go @@ -485,14 +485,14 @@ func (r *Runner) logExecute(name string, err error, out io.Reader) { execLog = fmt.Sprint(log.Cyan("\n EXECUTE > "), log.Bold(name)) } - if execLog != "" { - log.Info(execLog) - } - if err == nil && r.SkipSettings.SkipExecutionOutput() { return } + if execLog != "" { + log.Info(execLog) + } + if out != nil { log.Info(out) } From bef3364aa93ebc4074d0674c2423aeb9bb09c7e3 Mon Sep 17 00:00:00 2001 From: Valentin Kiselev Date: Tue, 18 Jul 2023 10:31:48 +0300 Subject: [PATCH 4/4] fix: correct skips for execution info and out --- internal/lefthook/runner/runner.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/lefthook/runner/runner.go b/internal/lefthook/runner/runner.go index c1b9ff22..92f67d87 100644 --- a/internal/lefthook/runner/runner.go +++ b/internal/lefthook/runner/runner.go @@ -485,14 +485,14 @@ func (r *Runner) logExecute(name string, err error, out io.Reader) { execLog = fmt.Sprint(log.Cyan("\n EXECUTE > "), log.Bold(name)) } - if err == nil && r.SkipSettings.SkipExecutionOutput() { - return - } - if execLog != "" { log.Info(execLog) } + if err == nil && r.SkipSettings.SkipExecutionOutput() { + return + } + if out != nil { log.Info(out) }