From 7ec05db28286600eca456645333f55c238259d0c Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 5 Sep 2025 15:50:57 -0400 Subject: 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 --- Omni/Ide/hooks/commit-msg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3