1+ #! /bin/sh
2+ # Commit-msg hook to block Co-Authored-By lines
3+ # GraphDone does not use pair programming and maintains clean git logs
4+
5+ # First argument is the commit message file
6+ COMMIT_MSG_FILE=" $1 "
7+
8+ # Read the commit message
9+ if [ ! -f " $COMMIT_MSG_FILE " ]; then
10+ exit 0
11+ fi
12+
13+ COMMIT_MSG=$( cat " $COMMIT_MSG_FILE " )
14+
15+ # Function to check for co-author patterns
16+ check_coauthor_patterns () {
17+ echo " $1 " | grep -iE " (co-authored-by:|co-author:|coauthor:|pair[- ]programm)" > /dev/null 2>&1
18+ }
19+
20+ # Check for Co-Authored-By and related patterns
21+ if check_coauthor_patterns " $COMMIT_MSG " ; then
22+ echo " "
23+ echo " ════════════════════════════════════════════════════════════════════"
24+ echo " ❌ COMMIT BLOCKED "
25+ echo " ════════════════════════════════════════════════════════════════════"
26+ echo " "
27+ echo " Co-authorship attribution detected in commit message."
28+ echo " "
29+ echo " GraphDone policy: Individual commits only (no pair programming)"
30+ echo " "
31+ echo " Found in your commit message:"
32+ echo " ────────────────────────────────────────────────────────────────────"
33+ echo " $COMMIT_MSG " | grep -iE " (co-authored-by:|co-author:|coauthor:|pair[- ]programm)" | head -5
34+ echo " ────────────────────────────────────────────────────────────────────"
35+ echo " "
36+ echo " Please remove:"
37+ echo " • Co-Authored-By: <name> <email>"
38+ echo " • Co-Author: ..."
39+ echo " • References to pair programming"
40+ echo " • Any collaborative attribution"
41+ echo " "
42+ echo " Each commit should have a single author for:"
43+ echo " ✓ Clear accountability"
44+ echo " ✓ Clean git history"
45+ echo " ✓ Accurate contribution tracking"
46+ echo " "
47+ echo " To fix: Edit your commit message and remove co-authorship lines"
48+ echo " ════════════════════════════════════════════════════════════════════"
49+ echo " "
50+ exit 1
51+ fi
52+
53+ # Also check for specific AI assistant attributions that might slip through
54+ if echo " $COMMIT_MSG " | grep -iE " (claude.*anthropic|generated.*by.*claude|claude.*ai|noreply@anthropic)" > /dev/null 2>&1 ; then
55+ echo " "
56+ echo " ════════════════════════════════════════════════════════════════════"
57+ echo " ⚠️ AI ATTRIBUTION DETECTED "
58+ echo " ════════════════════════════════════════════════════════════════════"
59+ echo " "
60+ echo " Found AI assistant attribution in commit message."
61+ echo " "
62+ echo " While AI tools may assist with code, commits should be"
63+ echo " attributed only to the human developer who reviewed and"
64+ echo " submitted the code."
65+ echo " "
66+ echo " Please remove any lines like:"
67+ echo " • Co-Authored-By: Claude <noreply@anthropic.com>"
68+ echo " • Generated with Claude"
69+ echo " • AI-assisted attribution"
70+ echo " "
71+ echo " ════════════════════════════════════════════════════════════════════"
72+ echo " "
73+ exit 1
74+ fi
75+
76+ # Check for suspiciously formatted email addresses that might be bots
77+ if echo " $COMMIT_MSG " | grep -iE " co-authored-by:.*<.*(bot|action|automated|ci-cd|pipeline).*@.*>" > /dev/null 2>&1 ; then
78+ echo " "
79+ echo " ⚠️ WARNING: Automated co-author detected"
80+ echo " Blocking bot/automation co-authorship attributions"
81+ echo " "
82+ exit 1
83+ fi
84+
85+ # All checks passed
86+ exit 0
0 commit comments