Skip to content

[webkitscmpy] Bypass default-branch check - #76103

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
JonWBedard:eng/webkitscmpy-Bypass-default-branch-check
Nov 7, 2026
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
JonWBedard:eng/webkitscmpy-Bypass-default-branch-check

Conversation

@JonWBedard

@JonWBedard JonWBedard commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

7994fb3

[webkitscmpy] Bypass default-branch check
https://bugs.webkit.org/show_bug.cgi?id=326580
rdar://189342331

Reviewed by Dewei Zhu.

Use the identifier cache instead of running merge-base to find a branch.

* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
(Git.commit):
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
(TestGit.test_commit_cached_hash_leaves_default_branch_without_identifier):
(TestGit.test_commit_cached_default_branch):
(TestGit.test_commit_cached_other_branch):
(TestGit.test_commit_cached_production_branch):

Canonical link: https://commits.webkit.org/325992@main

6f3be68

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios   🛠 mac   🛠 wpe   🛠 win ✅ 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-cmake-debug   🧪 wpe-wk2   🧪 win-tests ✅ 🛠 mac-apple
✅ 🧪 webkitperl   🧪 ios-wk2   🧪 api-mac   🧪 api-wpe ✅ 🛠 vision-apple
  🧪 webkitpy   🧪 ios-wk2-wpt   🧪 api-mac-cmake-debug   🧪 jsc-wpe
⏳ 🧪 api-ios   🧪 mac-wk2 ✅ 🛠 gtk3-gcc
  🧪 mac-cmake-debug-wk2 ✅ 🛠 gtk
✅ 🧪 services ✅ 🛠 vision   🧪 mac-wk2-stress   🧪 gtk-wk2
  🛠 vision-sim   🧪 mac-intel-wk2   🧪 api-gtk
✅ 🛠 🧪 unsafe-merge   🧪 vision-wk2   🛠 playstation
✅ 🛠 tv   🧪 mac-site-isolation
✅ 🛠 tv-sim
  🛠 watch
✅ 🛠 watch-sim

@JonWBedard JonWBedard self-assigned this Oct 6, 2026
@JonWBedard JonWBedard added the Tools / Tests Tools in the Tools directory, build issues, test infrastructure, and bugs in test cases label Oct 6, 2026
@JonWBedard JonWBedard added the skip-ews Applied to prevent a change from being run on EWS label Oct 6, 2026
Comment on lines +922 to +923
# Avoid a merge-base call for commits on main which are already in our cache
cached_identifier = Commit._parse_identifier(self.cache.to_identifier(hash=hash, populate=False)) if self.cache else None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This does make behaviour incorrect when the cache is incorrect (e.g., someone having committed on main, then pushed and reset main back to origin/main).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's true. Although in that case, it's a caching bug. I know I've heard rumors of such a bug, but I've never been able to catch it (and the cache is supposed to handle this case)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Managed to repro it. Fix is up in #76262

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm writing a longer review of that; I think the risk might be a bit too high with trusting the cache unconditionally in local development where non-fast-forward commits are relatively common for now, but I wouldn't be opposed to landing this behind an environment variable which we can set on commits.webkit.org?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See JonWBedard#1 — I think this is inevitable, even with cache fixes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That test needs no mock changes, and it's a normal git-webkit workflow: commit on main, then run git-webkit pr. That creates eng/… with git checkout -b, then moves main back with git branch -f main remotes/origin/main (pull_request.py:354-358), without touching the identifier cache. With this PR, commit(hash=..., include_identifier=False) on that commit still says main instead of the PR branch:

% ./Tools/Scripts/test-webkitpy webkitscmpy.test.git_unittest
Suppressing most webkitpy logging while running unit tests.
[27/120] webkitscmpy.test.git_unittest.TestGit.test_commit_cached_hash_leaves_default_branch_without_identifier failed:
  test_commit_cached_hash_leaves_default_branch_without_identifier (webkitscmpy.test.git_unittest.TestGit)
  Traceback (most recent call last):
    File "Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py", line 184, in test_commit_cached_hash_leaves_default_branch_without_identifier
      self.assertEqual('eng/pull-request', repository.commit(hash=unpushed, include_identifier=False).branch)
  AssertionError: 'eng/pull-request' != 'main'
  - eng/pull-request
  + main

Ran 120 tests in 0.888s
FAILED (failures=1, errors=0)

#76262 doesn't fix this on its own: commit() reads the cache with populate=False, so the answer stays wrong until something repopulates main. With both PRs applied the test still fails.

There are relatively cheap ways to make this safe, though. Most obviously, the cache could store the commit each default-branch ref pointed to when it was populated, and check those still match before trusting a cached identifier. Git.remote_for already runs git for-each-ref --format '%(objectname) %(refname)' over explicit refs, which is the same check.

@gsnedders gsnedders left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See the test I put in a PR again your branch — I think we need some cache invalidation, otherwise workloads unlike commits.webkit.org simply won't handle cases non-fast-forward default branch cases.

Comment on lines +922 to +923
# Avoid a merge-base call for commits on main which are already in our cache
cached_identifier = Commit._parse_identifier(self.cache.to_identifier(hash=hash, populate=False)) if self.cache else None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That test needs no mock changes, and it's a normal git-webkit workflow: commit on main, then run git-webkit pr. That creates eng/… with git checkout -b, then moves main back with git branch -f main remotes/origin/main (pull_request.py:354-358), without touching the identifier cache. With this PR, commit(hash=..., include_identifier=False) on that commit still says main instead of the PR branch:

% ./Tools/Scripts/test-webkitpy webkitscmpy.test.git_unittest
Suppressing most webkitpy logging while running unit tests.
[27/120] webkitscmpy.test.git_unittest.TestGit.test_commit_cached_hash_leaves_default_branch_without_identifier failed:
  test_commit_cached_hash_leaves_default_branch_without_identifier (webkitscmpy.test.git_unittest.TestGit)
  Traceback (most recent call last):
    File "Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py", line 184, in test_commit_cached_hash_leaves_default_branch_without_identifier
      self.assertEqual('eng/pull-request', repository.commit(hash=unpushed, include_identifier=False).branch)
  AssertionError: 'eng/pull-request' != 'main'
  - eng/pull-request
  + main

Ran 120 tests in 0.888s
FAILED (failures=1, errors=0)

#76262 doesn't fix this on its own: commit() reads the cache with populate=False, so the answer stays wrong until something repopulates main. With both PRs applied the test still fails.

There are relatively cheap ways to make this safe, though. Most obviously, the cache could store the commit each default-branch ref pointed to when it was populated, and check those still match before trusting a cached identifier. Git.remote_for already runs git for-each-ref --format '%(objectname) %(refname)' over explicit refs, which is the same check.

@JonWBedard JonWBedard removed the skip-ews Applied to prevent a change from being run on EWS label Nov 6, 2026
@JonWBedard
JonWBedard force-pushed the eng/webkitscmpy-Bypass-default-branch-check branch from 2de06e3 to 2908b1a Compare November 6, 2026 21:31
@JonWBedard
JonWBedard requested a review from gsnedders November 6, 2026 21:41

@dewei-zhu dewei-zhu 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.

r=me

self.assertEqual(None, local.Git(self.path).commit(revision=10))

def test_commit_cached_default_branch(self):
with mocks.local.Git(self.path, git_svn=True, remote='[email protected]:{}'.format(self.path)), MockTime, LoggerCapture():

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.

nit: use f-string for new code?

@JonWBedard
JonWBedard force-pushed the eng/webkitscmpy-Bypass-default-branch-check branch from 2908b1a to 6f3be68 Compare November 7, 2026 00:26
@JonWBedard JonWBedard added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Nov 7, 2026
https://bugs.webkit.org/show_bug.cgi?id=326580
rdar://189342331

Reviewed by Dewei Zhu.

Use the identifier cache instead of running merge-base to find a branch.

* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
(Git.commit):
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
(TestGit.test_commit_cached_hash_leaves_default_branch_without_identifier):
(TestGit.test_commit_cached_default_branch):
(TestGit.test_commit_cached_other_branch):
(TestGit.test_commit_cached_production_branch):

Canonical link: https://commits.webkit.org/325992@main
@webkit-commit-queue
webkit-commit-queue force-pushed the eng/webkitscmpy-Bypass-default-branch-check branch from 6f3be68 to 7994fb3 Compare November 7, 2026 00:36
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 325992@main (7994fb3): https://commits.webkit.org/325992@main

Reviewed commits have been landed. Closing PR #76103 and removing active labels.

@webkit-commit-queue
webkit-commit-queue merged commit 7994fb3 into WebKit:main Nov 7, 2026
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tools / Tests Tools in the Tools directory, build issues, test infrastructure, and bugs in test cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants