From 0bf91666673a8a1f2f2213bd090318a643a1032f Mon Sep 17 00:00:00 2001 From: thethreemagi Date: Fri, 31 Jul 2026 17:47:52 +0100 Subject: [PATCH] Add commit-msg hook refusing AI attribution --- .githooks/commit-msg | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .githooks/commit-msg diff --git a/.githooks/commit-msg b/.githooks/commit-msg new file mode 100644 index 0000000..7648105 --- /dev/null +++ b/.githooks/commit-msg @@ -0,0 +1,31 @@ +#!/bin/sh +# +# Refuses AI attribution in commit messages. +# +# This repo is public, so history is the first thing an outside contributor +# sees. Attribution cannot be removed retroactively without rewriting every +# commit after it, and clones have already copied it. +# +# Enable after cloning: +# +# git config core.hooksPath .githooks +# chmod +x .githooks/commit-msg +# +# The Gitea web API cannot set the executable bit, so the chmod is required +# on first clone even though the file is committed. + +msg_file="$1" + +# Co-author trailers naming an assistant. +if grep -qiE 'co-?authored-?by:[[:space:]]*.*(claude|anthropic|copilot|cursor|codex|chatgpt|gpt-|gemini|aider|devin|llm|\bai\b)' "$msg_file"; then + echo "REFUSED: AI co-author trailer in commit message." >&2 + exit 1 +fi + +# Generated-with footers and the robot emoji. +if grep -qiE 'generated with|written by (claude|an? ai)|🤖' "$msg_file"; then + echo "REFUSED: AI attribution in commit message." >&2 + exit 1 +fi + +exit 0