mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-17 04:09:07 +02:00
AGENTS.md forbids attribution trailers, but a rule an agent has to go and read loses to the instruction it is handed every turn. CLAUDE.md now imports AGENTS.md so it is always in context; a commit-msg hook (via make setup-hooks) refuses the trailers at commit time; a CodeRabbit pre-merge check flags a PR whose description or commits carry them. The check reports rather than blocks, since the repository keeps CodeRabbit's request-changes workflow off; turning that on is a separate, repository-wide decision.
27 lines
1.1 KiB
Bash
Executable File
27 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Refuses commit messages that carry attribution trailers. Contributors own
|
|
# their contributions (AGENTS.md, "No Co-Authored-By or tool-attribution
|
|
# trailers"); a trailer spreads that ownership onto a tool or a bystander.
|
|
|
|
msg_file="$1"
|
|
|
|
# Trailer keys in any casing, with any bullet or emoji in front.
|
|
trailers='^[^[:alnum:]]*(co-authored-by|claude-session|generated-by):'
|
|
# "Generated with/by" footers, including "Generated with <emoji> by".
|
|
footer='^[^[:alnum:]]*generated (with|by)( [^[:alnum:]]*by)? '
|
|
# A footer names a product, so a capitalized word must follow the phrase
|
|
# itself. Prose such as "generated by the protobuf compiler" stays legal.
|
|
tool='[Gg][Ee][Nn][Ee][Rr][Aa][Tt][Ee][Dd] ([Ww][Ii][Tt][Hh]|[Bb][Yy])( [^[:alnum:]]*[Bb][Yy])? [^[:alnum:]]*[A-Z]'
|
|
|
|
offending=$( {
|
|
grep -Ein "$trailers" "$msg_file"
|
|
grep -Ein "$footer" "$msg_file" | grep -E "$tool"
|
|
} | sort -un )
|
|
|
|
if [ -n "$offending" ]; then
|
|
echo "commit-msg: attribution trailers are not accepted in this repository:" >&2
|
|
printf '%s\n' "$offending" | sed 's/^/ /' >&2
|
|
echo "Remove them and commit again (see AGENTS.md)." >&2
|
|
exit 1
|
|
fi
|