Files
scaffold/template/scripts/check-claude-attribution.sh
T
baozaotumao f42633bbd2 feat: Claude 署名开关 + commit-msg 门禁(生成项目自带)
- template/scripts/claude-attribution.sh:一条命令切换本项目是否含 Claude 署名
  (on|off|status,存于 git config scaffold.includeClaude,默认 off)
- template/scripts/check-claude-attribution.sh:commit-msg 门禁逻辑,off 时自动
- .pre-commit-config 增加 commit-msg 阶段 local 钩子调用门禁
- copier.yml _tasks 默认 git config scaffold.includeClaude false
- 修复:template/scripts/*.sh 补可执行位(否则生成项目直接运行报 permission denied)
- README 加「Claude 署名策略」章节 + 文件树补 template/scripts/

验证:开关 on/off/status、门禁直接调用、经 pre-commit(language:system) 调用均生效,
off 剥除 / on 保留,copier 生成 rc=0、脚本可执行、门禁已挂载。
scaffold 仓库自身亦已装本地 commit-msg 钩子,保证本仓库今后不含 Claude 署名。
2026-06-02 02:56:02 -07:00

19 lines
798 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# commit-msg 门禁:按 scaffold.includeClaude 策略处理 Claude 署名。
# 由 pre-commit 在 commit-msg 阶段调用,参数 $1 为提交信息文件。
# off(默认):剥除 Co-Authored-By: Claude 行
# on :保留(./scripts/claude-attribution.sh on
set -euo pipefail
msg_file="${1:?用法: check-claude-attribution.sh <commit-msg-file>}"
include="$(git config --get scaffold.includeClaude 2>/dev/null || echo false)"
[ "$include" = "true" ] && exit 0
if grep -qiE 'co-authored-by:.*claude' "$msg_file"; then
tmp="$(mktemp)"
grep -viE 'co-authored-by:.*claude' "$msg_file" >"$tmp"
mv "$tmp" "$msg_file"
echo "🛡 已移除 Claude 署名(scaffold.includeClaude=false;保留请运行 ./scripts/claude-attribution.sh on"
fi
exit 0