Skip to content

Commit 676ffb9

Browse files
committed
export-w3c-test-changes creates duplicate branches instead of updating pre-existing export branch
https://bugs.webkit.org/show_bug.cgi?id=296656 rdar://156960581 Reviewed by Tim Nguyen. Before 296936@main, the branch name got a suffix if `git show-ref --verify --quiet {branch_name}` == 0. However, the branch name would never match with the ref since it didn't have the "refs/heads" prefix. 296936@main fixed this by using `branches_for`, but the duplicate branching is actually not what we want. Having an existing branch get updated with new changes is the desired behaviour, so this PR removes the logic in `_ensure_new_branch_name` and simply creates a branch name with the `wpt-export-for-webkit-` prefix. * Tools/Scripts/webkitpy/w3c/test_exporter.py: (WebPlatformTestExporter._branch_name): (WebPlatformTestExporter._ensure_wpt_repository): (WebPlatformTestExporter.create_wpt_pull_request): (WebPlatformTestExporter._ensure_new_branch_name): Deleted. Canonical link: https://commits.webkit.org/298053@main
1 parent 4040e34 commit 676ffb9

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

Tools/Scripts/webkitpy/w3c/test_exporter.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ def _wpt_fork_push_url(self):
125125
@property
126126
@memoized
127127
def _branch_name(self):
128-
return self._ensure_new_branch_name()
128+
if not self._bug_id:
129+
commit = self._repository.find(self._options.git_commit)
130+
commit_hash = commit.hash[:7] if commit else '0'
131+
return f"wpt-export-for-webkit-{(str(self._bug_id) if self._bug_id else commit_hash)}"
129132

130133
@property
131134
@memoized
@@ -220,17 +223,6 @@ def _ensure_wpt_repository(self):
220223
self._linter = self._linter(self._options.repository_directory, self._host.filesystem)
221224
return True
222225

223-
def _ensure_new_branch_name(self):
224-
branch_name_prefix = "wpt-export-for-webkit-" + (str(self._bug_id) if self._bug_id else "0")
225-
branch_name = branch_name_prefix
226-
counter = 0
227-
branches_for = self._wpt_repo.branches_for()
228-
while branch_name in branches_for:
229-
# FIXME: If the branch exists, we should give the option to overwrite or rebase - https://bugs.webkit.org/show_bug.cgi?id=295350
230-
branch_name = (f'{branch_name_prefix}-{counter!s}')
231-
counter = counter + 1
232-
return branch_name
233-
234226
def clean(self):
235227
_log.info('Cleaning web-platform-tests master branch')
236228
self._run_wpt_git(['checkout', self._wpt_repo.default_branch])
@@ -308,6 +300,7 @@ def make_pull_request(self):
308300
def create_wpt_pull_request(self, remote_branch_name, title, body):
309301
_log.info(f"\nCreating pull-request for '{remote_branch_name}'...")
310302

303+
# FIXME: If the pull request/branch exists, we should give the option to overwrite or rebase - https://bugs.webkit.org/show_bug.cgi?id=295350
311304
pr = self._remote.pull_requests.create(
312305
title=title,
313306
body=body,

0 commit comments

Comments
 (0)