From 29594212f3c491a250939274109d24bf322de31a Mon Sep 17 00:00:00 2001 From: Beatriz Vieira Date: Thu, 25 Feb 2021 21:22:28 -0300 Subject: [PATCH] fix(validate-commit-message): ignore validation when source is merge issue: #11 --- cmd/git-sv/handlers.go | 5 +++++ cmd/git-sv/main.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/git-sv/handlers.go b/cmd/git-sv/handlers.go index 206f194..efe9fc4 100644 --- a/cmd/git-sv/handlers.go +++ b/cmd/git-sv/handlers.go @@ -376,6 +376,11 @@ func validateCommitMessageHandler(git sv.Git, messageProcessor sv.MessageProcess return nil } + if source := c.String("source"); source == "merge" { + warn("commit message validation skipped, ignoring source: %s...", source) + return nil + } + filepath := filepath.Join(c.String("path"), c.String("file")) commitMessage, err := readFile(filepath) diff --git a/cmd/git-sv/main.go b/cmd/git-sv/main.go index d39f5c5..885b68f 100644 --- a/cmd/git-sv/main.go +++ b/cmd/git-sv/main.go @@ -144,7 +144,7 @@ func main() { { Name: "validate-commit-message", Aliases: []string{"vcm"}, - Usage: "use as prepare-commit-message hook to validate message", + Usage: "use as prepare-commit-message hook to validate and enhance commit message", Action: validateCommitMessageHandler(git, messageProcessor), Flags: []cli.Flag{ &cli.StringFlag{Name: "path", Required: true, Usage: "git working directory"},