Skip to content

fix(review): 修复 base 分支推进导致的 PR diff 误退出 - #331

Merged
Terry-Mao merged 3 commits into
mainfrom
fix/review-diff-base-advance-328
Nov 3, 2026
Merged

Terry-Mao merged 3 commits into
mainfrom
fix/review-diff-base-advance-328

Conversation

@Terry-Mao

@Terry-Mao Terry-Mao commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • 移除审查 diff 生成时对实时 base 分支顶端 SHA 的比较,避免 base 正常推进时误退出。
  • 本地缺少预期 base 提交时,从目标仓库抓取 base ref 并确认预期 SHA 已到位;随后按快照 base/head 的共同祖先生成 diff。
  • 保留生成前后的 PR API 快照校验,并增加普通 PR 与 fork PR 在 base 推进场景下的真实 Git 历史回归测试。

Fixes #328

Testing

  • PYTHONDONTWRITEBYTECODE=1 /tmp/aicodingflow-issue-328-py313/bin/python -m unittest discover -s .github/aicodingflow-tests:524 项通过(同步最新 main 后;临时 Python 3.13 环境安装了 CI 声明的依赖)。
  • git diff --check origin/main...HEAD:通过。
  • PR 正文校验:通过。

Risk

  • 如果预期 base SHA 在目标仓库当前 base ref 的历史中已不可达,补取后会明确失败;不会使用实时分支顶端代替 PR 快照。

How to revert

  • 按逆序执行 git revert 52a6d21 18e017f,撤销本 PR 的两个修复提交。

@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.

该改动解决了同仓库 base 推进导致的误退出,但会使手动 workflow_dispatch 审查 fork PR 的既有路径回归:worktree 只检出 head 仓库,无法保证包含 base 仓库的 base.sha。建议补齐缺对象时的精确 SHA fetch,并增加 fork + base 已推进的回归测试。

Comment thread .github/scripts/build_pr_diff.py Resolved

@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.

修复使用事件快照中的 base SHA 计算合并基点,并在本地缺少该提交时补取 base ref,同时保留生成前后的 PR 快照校验。新增回归测试覆盖了 base 分支推进及 fork 缺少快照 base 对象的场景;未发现需要阻止合并的问题。

@Terry-Mao
Terry-Mao merged commit 7e5ac20 into main Nov 3, 2026
4 checks passed
@Terry-Mao
Terry-Mao deleted the fix/review-diff-base-advance-328 branch November 3, 2026 13:20
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.

GitHub PR base changed while fetching review diff 退出的问题

1 participant