summaryrefslogtreecommitdiff
path: root/Omni
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-09-05 15:50:57 -0400
committerBen Sima <ben@bsima.me>2025-09-05 16:09:01 -0400
commit7ec05db28286600eca456645333f55c238259d0c (patch)
tree5c1aa47e2d4dc2807bedbbf80cb0fed3a12b4911 /Omni
parent8f381492ce545bcfe6608f56c0134c26f42f0506 (diff)
Strip comment lines and diff in commit-msg hook
Without this, my custom git commit template will get mangled into the commit message with the call to fmt. I guess git strips all of this stuff *after* it runs the commit-msg hook. Oy vey. diff --git a/Omni/Ide/hooks/commit-msg b/Omni/Ide/hooks/commit-msg index c15b4a1..bfbb06f 100755 --- a/Omni/Ide/hooks/commit-msg +++ b/Omni/Ide/hooks/commit-msg @@ -1,6 +1,7 @@ #!/usr/bin/env bash temp=$(mktemp) -fmt -w 72 -u "$1" > "$temp" +# strip comment lines and everything after >8 cut line +sed '/^#/d; /^# -\+ >8 -\+/,$d' "$1" | fmt -w 72 -u > "$temp" mv "$temp" "$1" if ! gitlint --ignore-stdin --staged --msg-filename "$1" run-hook; then backup="$CODEROOT"/.git/COMMIT_EDITMSG.backup
Diffstat (limited to 'Omni')
-rwxr-xr-xOmni/Ide/hooks/commit-msg3
1 files changed, 2 insertions, 1 deletions
diff --git a/Omni/Ide/hooks/commit-msg b/Omni/Ide/hooks/commit-msg
index c15b4a1..c6197f9 100755
--- a/Omni/Ide/hooks/commit-msg
+++ b/Omni/Ide/hooks/commit-msg
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
temp=$(mktemp)
-fmt -w 72 -u "$1" > "$temp"
+# strip everything after >8 cut line, then strip comment lines
+sed '/.*>8.*/,$d; /^#/d' "$1" | fmt -w 72 -u > "$temp"
mv "$temp" "$1"
if ! gitlint --ignore-stdin --staged --msg-filename "$1" run-hook; then
backup="$CODEROOT"/.git/COMMIT_EDITMSG.backup