Files
youle_framework/.githooks/pre-commit
T
joywayerandClaude Opus 4.8 abc6281ec0 回迁工具:check-redlines 增量模式(--staged-diff)+ 存量扫描(--scan-all)+ setup 脚本
为「老项目回迁这套强制体系」补三件套,核心是不搞大爆炸清理:

- check-redlines.js:新增 --staged-diff(只查本次新增行,老代码存量违规不阻塞,
  新代码从此强制合规)与 --scan-all(可编辑正式代码 ES5 存量违规,只报不挡)。
- .githooks/pre-commit:按本地 git 配置 redlines.stagedmode 选严格(整文件)/增量(新增行)。
- setup-redlines.sh:一键激活+自检——迁移清单、node/权限、set core.hooksPath、
  存量扫描;`--diff` 一键切增量模式供老项目用。
- 已测:scan-all 报本仓库 0 存量违规;增量模式放行含老违规文件的干净新增行、
  拦新增违规行;严格模式整文件拦;setup 幂等且模板保持严格。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 13:19:27 +08:00

11 lines
771 B
Bash
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.
#!/bin/sh
# 机械红线校验:对本次暂存做「可编辑范围 + 严格 ES5」硬检查,命中即阻断提交。
# 工具无关——Claude Code、别的编辑器、人手改,提交都过这道闸。
# 模式(本地 git 配置 redlines.stagedmode):
# 未设 / 非 diff → 严格:整文件扫描(模板等干净仓库用)
# diff → 增量:只查本次新增行(已有开发量的老项目回迁用)
# 启用(每个克隆一次性):git config core.hooksPath .githooks (或跑 setup-redlines.sh)
MODE="$(git config --get redlines.stagedmode 2>/dev/null)"
if [ "$MODE" = "diff" ]; then FLAG="--staged-diff"; else FLAG="--staged"; fi
exec node "$(git rev-parse --show-toplevel)/.claude/hooks/check-redlines.js" "$FLAG"