From 28a40c430e989c5bc949e074bceda6b891902287 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 8 Apr 2024 18:33:02 -0400 Subject: Save commit message if gitlint fails I got annoyed losing my well-crafted commit message one too many times. --- Biz/Ide/hooks/commit-msg | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Biz/Ide/hooks/commit-msg b/Biz/Ide/hooks/commit-msg index 64e400d..e07d1f4 100755 --- a/Biz/Ide/hooks/commit-msg +++ b/Biz/Ide/hooks/commit-msg @@ -1,2 +1,7 @@ #!/usr/bin/env bash -gitlint --ignore-stdin --staged --msg-filename "$1" run-hook +if ! gitlint --ignore-stdin --staged --msg-filename "$1" run-hook; then + backup="$CODEROOT"/.git/COMMIT_EDITMSG.backup + cp "$CODEROOT"/.git/COMMIT_EDITMSG "$backup" + echo "error: gitlint failed, saved your commit msg as $backup" + exit 1 +fi -- cgit v1.2.3