Skip to content

[CI] Use --merge-base in check_approval.sh to ensure correct diff scope#7601

Merged
EmmonsCurse merged 1 commit into
PaddlePaddle:developfrom
EmmonsCurse:fix_approve_check
Apr 23, 2026
Merged

[CI] Use --merge-base in check_approval.sh to ensure correct diff scope#7601
EmmonsCurse merged 1 commit into
PaddlePaddle:developfrom
EmmonsCurse:fix_approve_check

Conversation

@EmmonsCurse
Copy link
Copy Markdown
Collaborator

@EmmonsCurse EmmonsCurse commented Apr 23, 2026

Motivation

Using git diff upstream/$BRANCH directly may include unrelated changes when the local branch is not strictly rebased, leading to incorrect detection results in CI checks.

Switching to --merge-base ensures that diffs are computed from the common ancestor of the branches, providing a more accurate and stable comparison baseline.

Modifications

  • Updated scripts/check_approval.sh to use:
    • git diff --merge-base upstream/$BRANCH
  • Applied this change consistently across all relevant diff checks in the script.
  • Ensured only actual changes introduced by the current branch are considered, avoiding false positives in log modification detection.

Usage or Command

N/A

Accuracy Tests

N/A

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Apr 23, 2026

Thanks for your contribution!

@EmmonsCurse
Copy link
Copy Markdown
Collaborator Author

EmmonsCurse commented Apr 23, 2026

/skip-ci all
/skip-ci ci_iluvatar
/skip-ci ci_hpu
/skip-ci build_xpu
/skip-ci build_gpu

Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Code Review | 2026-04-23 22:03:07

📋 Review 摘要

PR 概述:将 check_approval.sh 中所有 git diff upstream/$BRANCH 替换为 git diff --merge-base upstream/$BRANCH,确保 CI 审批检查仅基于当前分支实际引入的变更进行计算,避免因本地分支未严格 rebase 导致误判。
变更范围scripts/check_approval.sh(CI 审批脚本)
影响面 TagCI


问题

级别 文件 概述
❓ 疑问 scripts/check_approval.sh --merge-base 选项的 Git 版本兼容性

❓ 疑问:--merge-base 选项的 Git 版本兼容性

git diff --merge-base 是 Git 2.30.0(2020 年 12 月)引入的新选项。若 CI 环境的 Git 版本低于 2.30,该选项将导致命令失败,进而中断整个审批检查流程。

建议在合并前确认所有 CI Runner 的 Git 版本 ≥ 2.30,或考虑使用如下等价的向下兼容写法:

# 等价写法,兼容 git < 2.30
git diff $(git merge-base HEAD upstream/$BRANCH) -U0 | grep '^\+' | grep -zoE "PD_BUILD_(STATIC_)?OP" || true

总体评价

变更思路正确,使用 --merge-base 确实能更准确地界定 PR 引入的变更范围,解决了未严格 rebase 时 diff 范围偏大的问题。建议在合并前确认 CI 环境 Git 版本兼容性以规避潜在风险。

@EmmonsCurse EmmonsCurse merged commit 73f11e0 into PaddlePaddle:develop Apr 23, 2026
39 of 40 checks passed
@EmmonsCurse EmmonsCurse deleted the fix_approve_check branch April 23, 2026 14:14
xiaoguoguo626807 pushed a commit to xiaoguoguo626807/FastDeploy that referenced this pull request May 7, 2026
sunlei1024 pushed a commit to sunlei1024/FastDeploy that referenced this pull request May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants