Pull Request已成功合入, 合并人@CANN-robot
(感谢 汪超 的贡献)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 |
|---|---|---|
| repo-cann/cannbot-knowledge | ✅ zhanghz1, wangsj0012 (2/2) | ✅ zhanghz1 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
qq_41667743, thanks for your pull request. All authors of the commits have signed the CLA. 👍


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


The following labels are not ready.
approved: Please wait for committers to review the code.
lgtm: Please wait for committers to review the code.


pre-commit 会把匹配的文件批量追加到 entry 后面,实际执行形如 bash -n a.sh b.sh c.sh。Bash 只解析第一个脚本,其余路径成为该脚本的位置参数,不会被检查。因此,一次提交多个 Shell 文件时,只要错误文件没有排在某个执行批次的首位,Check shell syntax 就会错误地显示通过。
已复现: 在隔离 Git 仓库中原样使用该 hook,暂存 00.sh 至 15.sh 共 16 个 Bash 脚本;前 15 个内容合法,只有 15.sh 含非法语句 if then。使用 pre-commit 4.6.2、默认并发配置执行:
pre-commit run shell-syntax --all-files -v
→ Check shell syntax ... Passed;退出码 0
bash -n 15.sh
→ syntax error near unexpected token `then';退出码 2
这会使本 PR 新增的提交前检查无法可靠拦截 Shell 语法错误,不是单纯的提示或配置风格问题。
必须调整: 通过包装脚本逐个遍历 "$@",对每个文件执行 bash -n "$file",遇错返回非零。仅添加 require_serial: true 不能解决问题,因为串行执行仍会传入多个文件。包装逻辑可采用:
for file in "$@"; do
bash -n "$file" || exit $?
done
增加“同批次包含合法脚本及非首位错误脚本”的回归。已在临时夹具中验证上述修正:原错误样例被拒绝,pre-commit 退出 1;将错误脚本改为合法内容后退出 0。


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm


/approve


The MR can not be merged, because of CodeReview discussion not resolved
If you want to solve this problem, you can click here to do it in the FAQs.


Pull Request 说明
变更说明
新增precommit
变更类型
验证