Skip to content

feat(tools): report whether a branch is in step with main - #5168

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Dextroid17:feat/check-main-sync
Oct 14, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Dextroid17:feat/check-main-sync

Conversation

@Dextroid17

Copy link
Copy Markdown
Contributor

What

Adds tools/check_main_sync.py, an offline check a contributor runs before pushing or reporting a test result. It reports whether a branch is in step with main:

  • how many commits the branch is ahead of and behind main
  • whether git merge-tree merges it cleanly, and the conflicting files when it does not
  • the files changed on both sides since the merge base, and the merged pull requests that touched them

--fetch updates the base first, --strict also fails when the branch is behind, and the exit code is 1 on a conflict. It complements tools/pr_overlap.py, which compares open PRs with each other through the GitHub API; this compares one branch with main and needs only git.

Tested

Linux, git 2.56, Python 3. tools/tests/test_check_main_sync.py (7 tests, registered as check_main_sync) builds throwaway repositories for a level branch, a behind branch, a conflict, a clean merge with shared files, paths with spaces and non-ASCII characters, unrelated histories and a missing base. Breaking the conflict detection, the NUL splitting, --first-parent or the ahead/behind direction each fails the tests. Run against #4730's head it reports the CMakeLists.txt conflict and the merged PRs behind it. check_conventions.py passes. Not tested on Windows or macOS.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes

@github-actions github-actions Bot added the build label Oct 13, 2026
@johnmaia

Copy link
Copy Markdown
Contributor

Windows run, since the description says Windows is untested. Setup: Windows 11 (26300), WinLibs GCC 15.2.0 r7, Python 3.12, Git for Windows, Release, BUILD_TESTING=ON, ctest -j4 --timeout 300. Head 851b66b merged into main 69b4ca5.

AI-assisted: yes (Claude Code)

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked on the PR merged onto current main: check_main_sync passes, and fails when tools/check_main_sync.py is reverted. On this PR's own head against upstream/main the tool reports the merge as clean, CMakeLists.txt as changed on both sides, and the merged PRs that touched it. The Windows run by @johnmaia covers the platform the description left untested. Merging once the full Build is green.

@adriadam10
adriadam10 merged commit da4d5f2 into boykopovar:main Oct 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants