Skip to content

fix(axbuild): infer diff base for zero since ref#1143

Merged
ZR233 merged 1 commit into
devfrom
fix/zero-since
Jun 5, 2026
Merged

fix(axbuild): infer diff base for zero since ref#1143
ZR233 merged 1 commit into
devfrom
fix/zero-since

Conversation

@YanLien

@YanLien YanLien commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Problem

When a newly created remote branch triggers a push CI run for the first time, GitHub Actions sets github.event.before to the all-zero SHA. The CI passes that value to cargo xtask clippy --since, so the incremental diff base cannot be resolved and the check falls back to a full workspace run.

Changes

  • Teach the axbuild git helper to recognize an all-zero --since ref.
  • Infer the incremental diff base from the local git graph by using the parent of the first commit unique to the current branch.
  • Reuse the resolved diff base when classifying root Cargo.toml changes, so zero-since runs do not try to read old files from the all-zero ref.
  • Add unit coverage for first-push branch behavior, advanced default-branch tips, root Cargo.toml changes, and inference fallback.

@ZR233
ZR233 merged commit e16901d into dev Jun 5, 2026
290 of 294 checks passed
@ZR233
ZR233 deleted the fix/zero-since branch June 5, 2026 13:16
@github-actions github-actions Bot mentioned this pull request Jun 5, 2026

@mai-team-app mai-team-app 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 Summary

PR 做了什么
当新创建的远程分支首次触发 push CI 时,GitHub Actions 会将 github.event.before 设为全零 SHA。旧代码会直接 bail 并退回全量 workspace clippy。本 PR 教 axbuild 的 git helper 识别零 since ref,从本地 git graph 推断增量 diff base,并复用推断出的 base 来正确检测根 Cargo.toml 变更。

实现分析

  • changed_paths_sincechanged_paths_since_with_base 重构很干净,让 select_incremental_packages 能使用推断出的 diff base 而非原始零 SHA 来检查 root_manifest_change_since
  • infer_zero_since_diff_base 通过 git rev-list --reverse --parents HEAD --not <remote-refs> 找到当前分支第一个独有的 commit,取其 parent 作为 diff base,逻辑正确。
  • git_remote_refs_not_at_commit 只查 refs/remotes,在 CI push 场景下足够。
  • 错误处理全面,context 信息清晰。

测试覆盖

  • zero_since_on_new_branch_resolves_to_first_unique_parent:基本场景
  • zero_since_ignores_default_branch_tip_after_branch_fork:dev 在 fork 后有新 commit 的场景
  • zero_since_root_manifest_change_uses_inferred_base:端到端测试,验证 select_incremental_packages 在零 since 下正确检测 Cargo.toml 变更
  • zero_since_without_remote_refs_returns_error:无 remote ref 时的降级行为

CI 状态
Clippy (run_host) ✅ | Test starry riscv64 qemu (run_container) ✅ | Test arceos aarch64 qemu (run_host) ✅ | Test arceos riscv64 qemu (run_host) ✅ | Test starry self-hosted board orangepi-5-plus (run_host) ✅。skipped jobs 是 run_host/run_container 矩阵互斥的预期行为。

重复分析
无重叠 open PR。#1160 (Wayland)、#1159 (CI dedupe) 与本 PR 改动的 scripts/axbuild/src/support/git.rs 无关。

本地验证

  • cargo fmt --check
  • cargo clippy --all-features -- -D warnings
  • cargo test -- support::git 22/22 通过 ✅(含 4 个新增测试)

结论:代码逻辑正确、测试覆盖充分、CI 全部通过、无阻塞问题。APPROVE。

Powered by mimo-v2.5-pro

@github-actions github-actions Bot mentioned this pull request Jun 9, 2026
aptacc2421 pushed a commit to aptacc2421/tgoskits that referenced this pull request Jun 14, 2026
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.

2 participants