Skip to content

gh-145000: find correct merge base in check-html-ids#147975

Open
StanFromIreland wants to merge 4 commits intopython:mainfrom
StanFromIreland:fix-checck-html
Open

gh-145000: find correct merge base in check-html-ids#147975
StanFromIreland wants to merge 4 commits intopython:mainfrom
StanFromIreland:fix-checck-html

Conversation

@StanFromIreland
Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland commented Apr 1, 2026

github.event.pull_request.base.sha is not the same as the git merge-base, per https://github.com/orgs/community/discussions/39880. Instead compare the commits and use merge_base_commit (this also however has quite sparse docs :-( at https://docs.github.com/en/rest/commits/commits?apiVersion=2026-03-10&versionId=free-pro-team%40latest&category=commits&subcategory=commits#compare-two-commits).

@StanFromIreland StanFromIreland changed the title gh-146488: find correct merge base in check-html-ids gh-145000: find correct merge base in check-html-ids Apr 1, 2026
@webknjaz
Copy link
Copy Markdown
Member

webknjaz commented Apr 2, 2026

I'm not sure what GH puts into that response object.. But here's something I've been playing with on the Git level for gradually fetching older commits given a shallow clone, if you'd like to experiment with that: https://github.com/ansible/ansible/pull/84375/changes#diff-dfbae2cdf0eee1583a3eea53c82843bb9d1dfde27e6a3832e4ee48ab8aa2a1d3R226-R294.


Instead of having two git checkout steps, I'd go with one, then load more commits gradually until enough of the Git tree is in cache and use a git worktree to produce the second folder with older files. I'd maybe also factor-in the number of commits in the PR (as returned by the API) to start with.


Though, your solution might be functional, I don't have any experience with this specific API response key. I don't know if they'll produce different responses when there's multiple commits merging main into the topic branch.

@StanFromIreland
Copy link
Copy Markdown
Member Author

if you'd like to experiment with that: https://github.com/ansible/ansible/pull/84375/changes#diff-dfbae2cdf0eee1583a3eea53c82843bb9d1dfde27e6a3832e4ee48ab8aa2a1d3R226-R294.

Cool! I implemented it in bash.

@StanFromIreland
Copy link
Copy Markdown
Member Author

StanFromIreland commented Apr 2, 2026

It calculated the correct merge base :-)

MERGE_BASE: 9e5b8383724211d14165a32c0e7682e56e13843a

Edit: And it also calculated it correctly after updating the PR.

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