Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: skip summary separator if nothing is printed #575

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions internal/lefthook/lefthook.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import (
)

const (
hookFileMode = 0o755
envVerbose = "LEFTHOOK_VERBOSE" // keep all output
hookFileMode = 0o755
envVerbose = "LEFTHOOK_VERBOSE" // keep all output
oldHookPostfix = ".old"
)

var lefthookContentRegexp = regexp.MustCompile("LEFTHOOK")
Expand Down Expand Up @@ -94,7 +95,7 @@ func (l *Lefthook) cleanHook(hook string, force bool) error {
}

// Check if .old file already exists before renaming.
exists, err = afero.Exists(l.Fs, hookPath+".old")
exists, err = afero.Exists(l.Fs, hookPath+oldHookPostfix)
if err != nil {
return err
}
Expand All @@ -107,7 +108,7 @@ func (l *Lefthook) cleanHook(hook string, force bool) error {
}
}

err = l.Fs.Rename(hookPath, hookPath+".old")
err = l.Fs.Rename(hookPath, hookPath+oldHookPostfix)
if err != nil {
return err
}
Expand Down
10 changes: 8 additions & 2 deletions internal/lefthook/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,15 @@ func printSummary(
results []run.Result,
logSettings log.SkipSettings,
) {
summaryPrint := log.Separate

if logSettings.SkipExecution() || (logSettings.SkipExecutionInfo() && logSettings.SkipExecutionOutput()) {
summaryPrint = func(s string) { log.Info(s) }
}

if len(results) == 0 {
if !logSettings.SkipEmptySummary() {
log.Separate(
summaryPrint(
fmt.Sprintf(
"%s %s %s",
log.Cyan("summary:"),
Expand All @@ -195,7 +201,7 @@ func printSummary(
return
}

log.Separate(
summaryPrint(
log.Cyan("summary: ") + log.Gray(fmt.Sprintf("(done in %.2f seconds)", duration.Seconds())),
)

Expand Down