Repository navigation
[webkitscmpy] Bypass default-branch check - #76103
webkit-commit-queue merged 1 commit into
Conversation
|
EWS run on previous version of this PR (hash 2de06e3) Details |
| # 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 |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
See JonWBedard#1 — I think this is inevitable, even with cache fixes.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
| # 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 |
There was a problem hiding this comment.
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.
2de06e3 to
2908b1a
Compare
|
EWS run on previous version of this PR (hash 2908b1a) Details |
| 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(): |
There was a problem hiding this comment.
nit: use f-string for new code?
2908b1a to
6f3be68
Compare
|
EWS run on current version of this PR (hash 6f3be68) Details |
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 to
7994fb3
Compare
|
Committed 325992@main (7994fb3): https://commits.webkit.org/325992@main Reviewed commits have been landed. Closing PR #76103 and removing active labels. |
7994fb3
6f3be68
🛠 mac🛠 wpe🛠 win🧪 wpe-wk2🧪 win-tests🧪 ios-wk2🧪 api-mac🧪 api-wpe🧪 webkitpy🧪 ios-wk2-wpt🧪 api-mac-cmake-debug🧪 jsc-wpe🧪 mac-wk2🧪 mac-cmake-debug-wk2🧪 mac-wk2-stress🧪 gtk-wk2🛠 vision-sim🧪 mac-intel-wk2🧪 api-gtk🧪 vision-wk2🛠 playstation🧪 mac-site-isolation🛠 watch