diff --git a/internal/config/available_hooks.go b/internal/config/available_hooks.go index cdd46157..551d4d05 100644 --- a/internal/config/available_hooks.go +++ b/internal/config/available_hooks.go @@ -8,35 +8,35 @@ const GhostHookName = "prepare-commit-msg" // AvailableHooks - list of hooks taken from https://git-scm.com/docs/githooks. var AvailableHooks = [...]string{ - "pre-applypatch", - "applypatch-msg", - "post-applypatch", + "pre-commit", + "pre-push", "commit-msg", + "applypatch-msg", "fsmonitor-watchman", "p4-changelist", "p4-post-changelist", "p4-pre-submit", "p4-prepare-changelist", - "pre-commit", + "post-applypatch", + "post-checkout", "post-commit", - "pre-receive", - "proc-receive", - "post-receive", + "post-index-change", "post-merge", - "pre-rebase", - "rebase", - "update", - "post-update", + "post-receive", "post-rewrite", - "post-checkout", - "post-index-change", + "post-update", + "pre-applypatch", "pre-auto-gc", "pre-merge-commit", - "pre-push", + "pre-rebase", + "pre-receive", "prepare-commit-msg", + "proc-receive", "push-to-checkout", + "rebase", "reference-transaction", "sendemail-validate", + "update", } func HookUsesStagedFiles(hook string) bool { diff --git a/internal/lefthook/install.go b/internal/lefthook/install.go index 540e1b9c..3e77a78e 100644 --- a/internal/lefthook/install.go +++ b/internal/lefthook/install.go @@ -116,7 +116,14 @@ func (l *Lefthook) createHooksIfNeeded(cfg *config.Config, force bool) error { return nil } - log.Info(log.Cyan("SYNCING")) + log.Infof(log.Cyan("sync hooks")) + + var success bool + defer func() { + if !success { + log.Info(log.Cyan(": ❌")) + } + }() checksum, err := l.configChecksum() if err != nil { @@ -148,8 +155,11 @@ func (l *Lefthook) createHooksIfNeeded(cfg *config.Config, force bool) error { return err } + success = true if len(hookNames) > 0 { - log.Info(log.Cyan("SERVED HOOKS:"), log.Bold(strings.Join(hookNames, ", "))) + log.Info(log.Cyan(": ✔️"), log.Gray("("+strings.Join(hookNames, ", ")+")")) + } else { + log.Info(log.Cyan(": ✔️ ")) } return nil diff --git a/internal/lefthook/run.go b/internal/lefthook/run.go index f18f76f7..f315b9d6 100644 --- a/internal/lefthook/run.go +++ b/internal/lefthook/run.go @@ -80,7 +80,12 @@ func (l *Lefthook) Run(hookName string, args RunArgs, gitArgs []string) error { } if !logSettings.SkipMeta() { - log.Info(log.Cyan("Lefthook v" + version.Version(false))) + log.Info( + log.Cyan("lefthook"), + log.Gray(fmt.Sprintf("v%s,", version.Version(false))), + log.Gray("hook:"), + log.Bold(hookName), + ) } // This line controls updating the git hook if config has changed @@ -91,10 +96,6 @@ Run 'lefthook install' manually.`, ) } - if !logSettings.SkipMeta() { - log.Info(log.Cyan("RUNNING HOOK:"), log.Bold(hookName)) - } - // Find the hook hook, ok := cfg.Hooks[hookName] if !ok { @@ -173,14 +174,22 @@ func printSummary( ) { if len(results) == 0 { if !logSettings.SkipEmptySummary() { - log.Info(log.Cyan("\nSUMMARY: (SKIP EMPTY)")) + log.Info( + fmt.Sprintf( + "%s %s %s", + log.Cyan("summary:"), + log.Gray("(skip)"), + log.Yellow("empty"), + ), + ) } return } - log.Info(log.Cyan( - fmt.Sprintf("\nSUMMARY: (done in %.2f seconds)", duration.Seconds()), - )) + log.Info( + log.Cyan("\nsummary:"), + log.Gray(fmt.Sprintf("(done in %.2f seconds)", duration.Seconds())), + ) if !logSettings.SkipSuccess() { for _, result := range results { diff --git a/internal/lefthook/run/runner.go b/internal/lefthook/run/runner.go index 6ca98b1f..c598926c 100644 --- a/internal/lefthook/run/runner.go +++ b/internal/lefthook/run/runner.go @@ -470,12 +470,9 @@ func (r *Runner) logSkip(name, reason string) { } log.Info( - fmt.Sprintf( - "%s: %s %s", - log.Bold(name), - log.Gray("(skip)"), - log.Yellow(reason), - ), + log.Cyan(fmt.Sprintf("\n %s", log.Bold(name))), + log.Gray("(skip)"), + log.Yellow(reason), ) } @@ -489,9 +486,9 @@ func (r *Runner) logExecute(name string, err error, out io.Reader) { case r.SkipSettings.SkipExecutionInfo(): execLog = "" case err != nil: - execLog = fmt.Sprint(log.Red("\n EXECUTE > "), log.Bold(name)) + execLog = log.Red(fmt.Sprintf("\n %s > ", name)) default: - execLog = fmt.Sprint(log.Cyan("\n EXECUTE > "), log.Bold(name)) + execLog = log.Cyan(fmt.Sprintf("\n %s > ", name)) } if execLog != "" {