Merged
feat(pre-commit): 拦截类钩子报告统一落盘 pre-commit_reports + 健壮性与策略对齐 #12834
景明Add on Sep 23
feat(pre-commit): 拦截类钩子报告统一落盘 pre-commit_reports + 健壮性与策略对齐 #12834
Merged
Merged fromgitcode_lijd/ops-transformerfix_2intocann/ops-transformermaster
Pull Request has been successfully merged by CANN-robot.
(Thank you for 景明's contribution.)Sep 23 Associated issue: [Bug-Report|缺陷反馈]: matmulAllReduce example编译运行时报错找不到头文件
atomgit-bot
Sep 23 Comments:
Sep 23 Comments:
变更摘要
本 PR 为 pre-commit 拦截类钩子(codespell、OAT)引入报告持久化机制,将原先仅打印到终端的输出统一落盘到 pre-commit_reports/ 目录,便于事后排查拼写与合规问题。核心做法是新增 scripts/run_codespell.sh 包装脚本承接 codespell 输出,调整 scripts/oat_check.sh 的报告落点与文件名,并同步更新 .pre-commit-config.yaml 钩子 entry、.gitignore 忽略规则及开发文档说明。
主要改动
- 新增 codespell 报告包装脚本: 新增
scripts/run_codespell.sh,将codespell "$@"的输出通过tee同时写入pre-commit_reports/codespell.log,并以exit "${PIPESTATUS[0]}"保留原始退出码。 - codespell 钩子 entry 改写:
.pre-commit-config.yaml中codespell钩子的entry改为bash scripts/run_codespell.sh,使钩子经包装脚本执行以落盘报告。 - OAT 报告目录与文件名调整:
scripts/oat_check.sh中OAT_RESULT_DIR由$REPO_ROOT/oat_reports改为$REPO_ROOT/pre-commit_reports,报告文件由result.txt更名为oat_result.txt(批量与单文件两条写入路径同步更新)。 - 忽略规则同步:
.gitignore将oat_reports/替换为pre-commit_reports/,使新报告目录不被 git 跟踪。 format_cpp.sh目录校验修复:scripts/format_cpp.sh在目标目录不存在时,由仅打印提示改为输出错误信息到 stderr 并exit 1终止执行。


Incorrect?
Sep 23 Added label: cann-cla/yes
CANN-robot
Sep 23 Comments:
Sep 23 Comments:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| OAT.xml | ✅ 马兵, 蒋礼锐, wang-minbo (3/2) | ✅ 蒋礼锐, wang-minbo, 马兵 (3/1) |
| docs | ✅ 蒋礼锐, wang-minbo, 马兵 (3/2) | ✅ wang-minbo, 马兵, 蒋礼锐 (3/1) |
| scripts | ✅ 蒋礼锐, wang-minbo, 马兵 (3/2) | ✅ 蒋礼锐, wang-minbo, 马兵 (3/1) |
| sig-ops-transformer | ✅ 蒋礼锐, 马兵 (2/2) | ✅ 蒋礼锐, 马兵 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
gitcode_lijd, thanks for your pull request. All authors of the commits have signed the CLA. 👍


108 messages are collapsed here。 See more
Sep 29 Added label: approved
jiang-lirui
Sep 29 Comments:
Sep 29 Comments:
/approve
/lgtm


Sep 29 Added label: lgtm
Sep 29 Merged pull request
关联Issue https://gitcode.com/cann/ops-transformer/issues/5016
描述
🐛 Bug 修复 / ✨ 特性增强
围绕既有 pre-commit 体系的三处完善(8 文件 +38/-12,1 笔提交):拦截类钩子报告落盘、脚本健壮性修复、策略与文档对齐。全部经
--all-files全量实测校准。一、拦截类钩子报告统一落盘
pre-commit_reports/(不入 git)scripts/run_codespell.sh(新增)pre-commit_reports/codespell.log(entry 覆写仍跑托管 venv,PIPESTATUS保退出码).pre-commit-config.yamlscripts/oat_check.shoat_reports/result.txt→pre-commit_reports/oat_result.txt(单文件与批量两条写路径同步).gitignoreoat_reports/→pre-commit_reports/docs/zh/develop/pre-commit_guide.md自动修类钩子(clang-format/ruff)直接改好文件无需报告;拼写/合规须人工处理,报告落盘便于复查与喂给 agent 修复。
二、健壮性修复(姊妹仓全量实测暴露的同款隐患)
scripts/oat_check.sheval拼接改数组传参 +-f加引——文件名含()/&/[]/空格时 eval 会打断 shell 致扫描假死/假过(本仓当前 0 此类文件名,防御性修复)scripts/format_cpp.sh三、策略与文档对齐
OAT.xmlrequirements*.txt(依赖清单,双过滤器)、*.info(cmake help,双过滤器)——全量扫描 250→240,残留均为真实缺头债(增量消化)trailing-whitespace--markdown-linebreak-ext=md(防静默剥掉 md 双空格硬换行语法,实测:双空格保留、三空格收敛、单空格照删).clang-formatPointerAlignment改 Left(int* p指针随类型,领导确认口径;引用&同规则);年份 2025→2026测试
留作仓主决策(本 PR 不动)
--ignore现行清单含F841,F821,F401等 F 系列——skills-dev 口径为「F 系列全启用抓真 bug」,两仓策略不同,建议仓主确认后另行统一third_party/catlass、third_party/opbase下同名 oat_check.sh 为上游副本,未动类型标签