Skip to content

Commit b1526b0

Browse files
fix: strip co-author and Cursor trailers in commit-msg hook
1 parent 911cd6f commit b1526b0

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

.githooks/commit-msg

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
set -eu
33

4-
# Strip Cursor co-author trailer(s) from commit message.
4+
# Strip AI co-author/trailer lines from commit message.
55
# Runs after the message is composed, before the commit is finalized.
66
#
77
# Usage: enable repo hooks with:
@@ -14,12 +14,14 @@ fi
1414

1515
tmp="${MSG_FILE}.tmp.$$"
1616

17-
# Remove any "Co-authored-by: Cursor ..." trailer lines (case-insensitive).
18-
# Keep all other co-authors intact.
17+
# Remove:
18+
# - ALL "Co-authored-by:" trailer lines (case-insensitive)
19+
# - ANY git trailer line mentioning Cursor/cursoragent (case-insensitive)
1920
awk '
2021
BEGIN { IGNORECASE = 1 }
21-
/^[[:space:]]*Co-authored-by:[[:space:]]*Cursor([[:space:]]|<|$)/ { next }
22-
/^[[:space:]]*Co-Authored-By:[[:space:]]*Cursor([[:space:]]|<|$)/ { next }
22+
NR==1 { print; next }
23+
/^[[:space:]]*Co-authored-by:[[:space:]]*/ { next }
24+
/^[[:space:]]*[A-Za-z0-9-]+:[[:space:]]+.*(cursoragent|cursor).*/ { next }
2325
{ print }
2426
' "$MSG_FILE" > "$tmp"
2527

0 commit comments

Comments
 (0)