f42633bbd2
- 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 署名。
83 lines
2.1 KiB
Django/Jinja
83 lines
2.1 KiB
Django/Jinja
# 提交前自动跑的质量门禁。安装:pre-commit install
|
||
# 手动全量:pre-commit run --all-files
|
||
repos:
|
||
# 通用
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||
rev: v4.6.0
|
||
hooks:
|
||
- id: trailing-whitespace
|
||
- id: end-of-file-fixer
|
||
- id: check-yaml
|
||
- id: check-added-large-files
|
||
- id: detect-private-key
|
||
|
||
# 密钥扫描(防密钥误入库,配合 detect-private-key)
|
||
- repo: https://github.com/gitleaks/gitleaks
|
||
rev: v8.21.2
|
||
hooks:
|
||
- id: gitleaks
|
||
|
||
# 提交信息规范(Conventional Commits)
|
||
- repo: https://github.com/compilerla/conventional-pre-commit
|
||
rev: v3.4.0
|
||
hooks:
|
||
- id: conventional-pre-commit
|
||
stages: [commit-msg]
|
||
|
||
# Claude 署名门禁:按 scaffold.includeClaude 策略移除/保留(默认移除)
|
||
- repo: local
|
||
hooks:
|
||
- id: claude-attribution-gate
|
||
name: Claude 署名门禁
|
||
entry: bash scripts/check-claude-attribution.sh
|
||
language: system
|
||
stages: [commit-msg]
|
||
|
||
{%- if include_backend or include_agent %}
|
||
|
||
# Python(ruff 同时做 lint + format)
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||
rev: v0.6.9
|
||
hooks:
|
||
- id: ruff
|
||
args: [--fix]
|
||
- id: ruff-format
|
||
{%- endif %}
|
||
|
||
{%- if include_backend %}
|
||
|
||
- repo: local
|
||
hooks:
|
||
- id: mypy-backend
|
||
name: mypy (backend)
|
||
entry: bash -c 'cd backend && uv run mypy src'
|
||
language: system
|
||
files: ^backend/.*\.py$
|
||
pass_filenames: false
|
||
{%- endif %}
|
||
|
||
{%- if include_agent %}
|
||
|
||
- repo: local
|
||
hooks:
|
||
- id: mypy-agent
|
||
name: mypy (agent)
|
||
entry: bash -c 'cd agent && uv run mypy src'
|
||
language: system
|
||
files: ^agent/.*\.py$
|
||
pass_filenames: false
|
||
{%- endif %}
|
||
|
||
{%- if include_frontend %}
|
||
|
||
# 前端:lint + 类型检查
|
||
- repo: local
|
||
hooks:
|
||
- id: frontend-lint
|
||
name: eslint + tsc (frontend)
|
||
entry: bash -c 'cd frontend && pnpm lint && pnpm typecheck'
|
||
language: system
|
||
files: ^frontend/.*\.(ts|tsx)$
|
||
pass_filenames: false
|
||
{%- endif %}
|