From 586b84f4344f445fd632c934d85defbc89729761 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Thu, 9 Mar 2023 12:43:33 +0100 Subject: [PATCH] feat(lint-staged): better branch commit message policy Related to 56b9d22d4 --- .husky/commit-msg | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index b56767669..0659aa1c2 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,11 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npx --no -- commitlint --edit "$1" +# Only check commit message if commit on master or first commit on another +# branch to avoid bothering fix commits after reviews +# +# FIXME: does not properly run with git commit --amend +if [ "$(git rev-parse --abbrev-ref HEAD)" = master ] || [ "$(git rev-list --count master..)" -eq 0 ] +then + npx --no -- commitlint --edit "$1" +fi