Skip to content

fix(review-pr): 移除无效的事件判断 - #294

Merged
Terry-Mao merged 1 commit into
mainfrom
fix/remove-dead-pr-event-gate
Oct 16, 2026
Merged

Terry-Mao merged 1 commit into
mainfrom
fix/remove-dead-pr-event-gate

Conversation

@Terry-Mao

Copy link
Copy Markdown
Owner

变更

  • 移除 PR 审查工作流状态步骤中恒为真的 github.event_name != 'pull_request' 条件。
  • 更新工作流测试,明确校验同仓库 PR 和有效 head SHA 的状态上报条件。

验证

  • PYTHONPATH=/tmp/aicodingflow-test-deps PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s .github/aicodingflow-tests -p 'test_review_workflow_dispatch.py'(9 项通过)
  • actionlint .github/workflows/review-pr.yml
  • git diff --check

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论

本次变更可安全合并:删除的条件恒为真,行为无变化。

核查要点

  • 死代码认定成立:.github/workflows/review-pr.yml 的触发器仅有 workflow_dispatch、issue_comment、pull_request_target(第 4、9、11 行),不存在 pull_request 触发器,故 github.event_name != 'pull_request' 恒为真;删除后对 Mark PR review status pending 与 Mark PR review status complete 两个状态上报步骤无行为影响。
  • 改动精确且最小:仅删除恒真合取项;.github/workflows/review-pr.yml:103 与 .github/workflows/review-pr.yml:256 保留的 head_sha != '' && head_repo == github.repository 守卫仍承担“不向 fork 仓库 SHA 写入状态”的原意。
  • 测试同步加强:.github/aicodingflow-tests/test_review_workflow_dispatch.py:93 与 .github/aicodingflow-tests/test_review_workflow_dispatch.py:179 由分散的 assertIn 改为对完整 if 表达式做 assertEqual,与工作流实际字符串逐字一致,后续再引入冗余条件会被直接捕获。
  • 无遗漏引用:在 .github/、docs/、README.md、AGENTS.md 中检索 event_name != 'pull_request' 已无剩余引用,不存在因删除条件而失效的文档或其他测试断言。
  • 未发现安全相关风险,不涉及权限、密钥、输入校验或数据流变更。

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改动移除 review-pr.yml 两个状态上报步骤中恒为真的 github.event_name != 'pull_request' 条件,并同步收紧 workflow 测试断言,行为保持不变。

核对依据:

  • 该 workflow 的触发器只有 pull_request_target、issue_comment、workflow_dispatch,github.event_name 不可能等于 'pull_request',且现有测试已断言 on 中不存在 pull_request trigger,docs/product/wiki/summaries/pr-review-verdict.md 也记录了「review-pr.yml 不监听 GitHub pull_request 事件」,因此被删条件确为死代码。
  • 全仓库仅 review-pr.yml 写入 AI PR Review commit status,删除该条件不会引入重复状态上报。
  • 同仓库 head 限制仍由保留的 steps.pr.outputs.head_repo == github.repository 与 steps.pr.outputs.head_sha != '' 保证,fork PR 状态上报语义未改变。
  • 测试由 assertIn 改为对完整 if 字符串的 assertEqual,断言与 workflow 实际值一致,属于增强而非削弱。

未发现正确性、安全、错误处理、性能或文档一致性问题;无阻塞项。

@Terry-Mao
Terry-Mao merged commit e767f58 into main Oct 16, 2026
4 of 5 checks passed
@Terry-Mao
Terry-Mao deleted the fix/remove-dead-pr-event-gate branch October 16, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant