You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(tools): report whether a branch is in step with main - #5168
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
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 main69b4ca5.
check_main_sync passes, and the full suite passes 1082 of 1082.
On real branches in a Windows clone, with --base origin/main:
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withmain:maingit merge-treemerges it cleanly, and the conflicting files when it does not--fetchupdates the base first,--strictalso fails when the branch is behind, and the exit code is 1 on a conflict. It complementstools/pr_overlap.py, which compares open PRs with each other through the GitHub API; this compares one branch withmainand needs only git.Tested
Linux, git 2.56, Python 3.
tools/tests/test_check_main_sync.py(7 tests, registered ascheck_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-parentor the ahead/behind direction each fails the tests. Run against #4730's head it reports theCMakeLists.txtconflict and the merged PRs behind it.check_conventions.pypasses. Not tested on Windows or macOS.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repository