summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2024-04-08 18:33:02 -0400
committerBen Sima <ben@bsima.me>2024-04-10 19:56:46 -0400
commit28a40c430e989c5bc949e074bceda6b891902287 (patch)
tree7a56aa5bfec4415601f7479fc719e97a59d4e0d8
parentaa5f12a5a2365a35f17becc66cf7a67fa86a4440 (diff)
Save commit message if gitlint fails
I got annoyed losing my well-crafted commit message one too many times.
-rwxr-xr-xBiz/Ide/hooks/commit-msg7
1 files changed, 6 insertions, 1 deletions
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