已合并
fix pre-commit file change hook #92
fix pre-commit file change hook #92
已合并
chenyx_2012创建于 6月24日
chenyx_2012
chenyx_2012
6月24日

变更描述 / Description

修复OAT 扫描完成修改gitignore导致pre-commit 检查文件变更失败

改动类型 / Change Type

  • Closes #
  • References #

测试信息 / Testing

检查清单 / Checklist

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 chenyx_2012 的贡献)
CANN-robotCANN-robot成员
6月24日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
6月24日 评论:

CLA Signature Pass

chenyx_2012, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robot
CANN-robot成员
6月24日 评论:

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


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/infrastructure 宋常霞, shentukangjun (2/2) 宋常霞 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

chenyx_2012, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
atomgit-bot
atomgit-bot
6月24日 评论:

Based on the PR 描述和当前文件内容,我已理解变更的核心逻辑。以下是总结:

变更摘要

此 PR 修复了 docs/SC/pre-commit/oat_check.sh 脚本中 OAT 扫描完成后因修改 .gitignore 文件而导致 pre-commit 钩子检测到文件变更失败的问题。原脚本在检测到 .gitignore 中缺少 oat_reports/log/ 条目时,会主动向 .gitignore 文件追加写入这些条目,这触发了 pre-commit 对工作区文件变更的检查。修改后,脚本仅输出警告信息提示用户手动添加,不再自动修改 .gitignore 文件。

主要改动

  • 移除自动写入 .gitignore 的逻辑: 删除了原先在 oat_reports/log/ 条目缺失时自动 echo 追加到 .gitignore 的代码,改为仅通过 echo "[OAT] [WARNING]..." 输出提示信息,引导用户自行决定是否添加。
  • 简化步骤 4 的检查流程: docs/SC/pre-commit/oat_check.sh 第 130–135 行的循环体从「检测缺失 → 自动写入 + 警告」简化为「检测缺失 → 仅警告」,减少了对仓库工作区的副作用,避免干扰 pre-commit 的文件变更判定。
likedislike
不准确?
atomgit-bot
atomgit-bot
6月24日 评论:

代码审查

审查总结

优先级 数量
P0 0
P1 0
P2 1
P3 0

变更文件审查结果:

  • docs/SC/pre-commit/oat_check.sh — 发现 1 个问题(文档不一致)

整体风险评估: 低风险。代码改动本身逻辑正确,将自动修改 .gitignore 改为打印警告,解决了 PR 描述的 pre-commit 文件变更检查失败问题。唯一需要注意的是同级目录下的配置指导文档 (pre-commit配置指导书.md 第 333 行) 仍声称脚本会自动维护 .gitignore,现已与代码行为不一致,建议同步更新。

类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

likedislike
不准确?
atomgit-bot
atomgit-bot6月24日进行代码检视2
docs/SC/pre-commit/oat_check.sh
已过期
@@ -132,3 +132,2 @@
132132 if ! grep -qE "^${_entry}/?$" "$_GITIGNORE" 2>/dev/null; then
133- printf "\n%s/\n" "$_entry" >> "$_GITIGNORE" 2>/dev/null || true
134- echo "[OAT] Added ${_entry}/ to .gitignore"
133+ echo "[OAT] [WARNING] '${_entry}/' is not in .gitignore. Consider adding it to avoid committing scan artifacts."
atomgit-bot
atomgit-bot6月24日评论:

🟡 Medium Priority

此 diff 移除了脚本自动向 .gitignore 追加 oat_reports/log/ 条目的逻辑(原第 133-134 行的 printf … >> "$_GITIGNORE"),改为仅打印警告(新第 133 行)。

但同目录下的文档 pre-commit配置指导书.md 第 333 行仍写着:

oat_reports/ 目录会被脚本自动加入 .gitignore,无需手动维护。

该文档声明现在与代码实际行为矛盾:脚本不再自动维护 .gitignore,用户若不手动添加,扫描产物(oat_reports/result.txt)将成为 untracked 文件,可能被误提交。该文档虽然不在本次变更文件列表中,但其描述已因本次 diff 变为错误信息,会误导使用者。

建议:同步更新 pre-commit配置指导书.md 第 333 行,将"自动加入"改为"如未加入会打印警告,请手动添加",例如:

oat_reports/ 目录需手动加入 .gitignore;若未加入,脚本会在每次提交时打印警告提示。

likedislike
不准确?
System
系统消息系统
6月25日 评论:

changed this line on b1101f01 view diff detail

chenyx_2012chenyx_2012
6月25日 推送  1 个提交:b1101f01-fix much commit bug
CANN-robotCANN-robot成员
6月25日 添加了label:stat/needs-squash
chenyx_2012chenyx_2012
6月26日 推送  1 个提交:7bc74a75-fix pip bug
chenyx_2012chenyx_2012
6月29日 推送  1 个提交:8f67928d-add CI mode check
chenyx_2012chenyx_2012
6月30日 推送  1 个提交:a6061621-fix error type
chenyx_2012chenyx_2012
7月8日 推送  1 个提交:48ece72b-fix eval problem
songchangxia成员
8月1日 评论:

/compile

likedislike
songchangxia成员
8月1日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
8月1日 添加了label:approved
CANN-robotCANN-robot成员
8月1日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
8月1日 评论:

流水线任务触发成功
任务链接 [0eac3b6b2390426f8435161239c65102][流水线指导]

任务名称状态日志下载链接
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
codecheck_style ✅ SUCCESS >>>>>
precommit ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>

[2026-08-01 13:25:06]    CI执行结束

likedislike
CANN-robotCANN-robot成员
8月1日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
8月1日 添加了label:ci-pipeline-passed
shentukangjun成员
8月1日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
8月1日 添加了label:lgtm
CANN-robotCANN-robot成员
8月1日 解决了最后一个问题
CANN-robotCANN-robot成员
8月1日 合入了pull request