Diff
Modified: trunk/Tools/ChangeLog (292537 => 292538)
--- trunk/Tools/ChangeLog 2022-04-07 15:29:42 UTC (rev 292537)
+++ trunk/Tools/ChangeLog 2022-04-07 16:09:50 UTC (rev 292538)
@@ -1,3 +1,28 @@
+2022-04-07 Jonathan Bedard <jbed...@apple.com>
+
+ [git-webkit] Clear merging-blocked label on PR update
+ https://bugs.webkit.org/show_bug.cgi?id=238907
+ <rdar://problem/91380962>
+
+ Reviewed by Aakash Jain.
+
+ * Scripts/libraries/webkitbugspy/setup.py: Bump version.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py: Ditto.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/github.py:
+ (Tracker.set): Empty list should trigger request.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/issue.py:
+ (Issue.set_labels): Pass self to tracker.set.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py:
+ (GitHub.__init__): Set self.labels from passed argument.
+ (GitHub._issue): Handle empty list.
+ * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
+ (PullRequest): Add BLOCKED_LABEL constant.
+ (PullRequest.main): Remove 'merging-blocked' label from existing pull-request
+ before updating pull-request.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:
+
2022-04-06 Jonathan Bedard <jbed...@apple.com>
[Merge-Queue] Share code for _addToLog
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/setup.py (292537 => 292538)
--- trunk/Tools/Scripts/libraries/webkitbugspy/setup.py 2022-04-07 15:29:42 UTC (rev 292537)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/setup.py 2022-04-07 16:09:50 UTC (rev 292538)
@@ -30,7 +30,7 @@
setup(
name='webkitbugspy',
- version='0.5.1',
+ version='0.5.2',
description='Library containing a shared API for various bug trackers.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py (292537 => 292538)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py 2022-04-07 15:29:42 UTC (rev 292537)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py 2022-04-07 16:09:50 UTC (rev 292538)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(0, 5, 1)
+version = Version(0, 5, 2)
from .user import User
from .issue import Issue
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/github.py (292537 => 292538)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/github.py 2022-04-07 15:29:42 UTC (rev 292537)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/github.py 2022-04-07 16:09:50 UTC (rev 292538)
@@ -356,7 +356,7 @@
if version:
labels.append(version)
- if labels:
+ if labels is not None:
for label in labels:
if not self.labels.get(label):
raise ValueError("'{}' is not a label for '{}'".format(label, self.url))
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py (292537 => 292538)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py 2022-04-07 15:29:42 UTC (rev 292537)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py 2022-04-07 16:09:50 UTC (rev 292538)
@@ -161,7 +161,7 @@
return self._labels
def set_labels(self, labels):
- return self.tracker.set(labels=labels)
+ return self.tracker.set(self, labels=labels)
@property
def project(self):
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py (292537 => 292538)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py 2022-04-07 15:29:42 UTC (rev 292537)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py 2022-04-07 16:09:50 UTC (rev 292538)
@@ -72,8 +72,7 @@
'{}_TOKEN'.format(prefix): 'token',
})
- if not labels:
- self.labels = self.DEFAULT_LABELS
+ self.labels = labels or self.DEFAULT_LABELS
def __enter__(self):
self._environment.__enter__()
@@ -129,7 +128,7 @@
if data.get('state') == 'closed':
issue['opened'] = False
- if data.get('labels'):
+ if data.get('labels', None) is not None:
issue['labels'] = []
issue['component'] = None
issue['version'] = None
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (292537 => 292538)
--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-04-07 15:29:42 UTC (rev 292537)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-04-07 16:09:50 UTC (rev 292538)
@@ -29,7 +29,7 @@
setup(
name='webkitscmpy',
- version='4.9.0',
+ version='4.9.1',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (292537 => 292538)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-04-07 15:29:42 UTC (rev 292537)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-04-07 16:09:50 UTC (rev 292538)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(4, 9, 0)
+version = Version(4, 9, 1)
AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py (292537 => 292538)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py 2022-04-07 15:29:42 UTC (rev 292537)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py 2022-04-07 16:09:50 UTC (rev 292538)
@@ -36,6 +36,7 @@
name = 'pull-request'
aliases = ['pr', 'pfr', 'upload']
help = 'Push the current checkout state as a pull-request'
+ BLOCKED_LABEL = 'merging-blocked'
@classmethod
def parser(cls, parser, loggers=None):
@@ -169,11 +170,35 @@
else:
branch_point = Branch.branch_point(repository)
- rmt = repository.remote(name=source_remote)
- if not rmt:
+ remote_repo = repository.remote(name=source_remote)
+ if not remote_repo:
sys.stderr.write("'{}' doesn't have a recognized remote\n".format(repository.root_path))
return 1
- target = 'fork' if isinstance(rmt, remote.GitHub) else source_remote
+
+ existing_pr = None
+ if remote_repo.pull_requests:
+ for pr in remote_repo.pull_requests.find(opened=None, head=repository.branch):
+ existing_pr = pr
+ if existing_pr.opened:
+ break
+ if existing_pr and not existing_pr.opened and not args.defaults and (args.defaults is False or Terminal.choose(
+ "'{}' is already associated with '{}', which is closed.\nWould you like to create a new pull-request?".format(
+ repository.branch, existing_pr,
+ ), default='No',
+ ) == 'Yes'):
+ existing_pr = None
+
+ # Remove "merging-blocked" label
+ if existing_pr and existing_pr._metadata and existing_pr._metadata.get('issue'):
+ log.info("Checking PR labels for '{}'...".format(cls.BLOCKED_LABEL))
+ pr_issue = existing_pr._metadata['issue']
+ labels = pr_issue.labels
+ if cls.BLOCKED_LABEL in labels:
+ log.info("Removing '{}' from PR {}...".format(cls.BLOCKED_LABEL, existing_pr.number))
+ labels.remove(cls.BLOCKED_LABEL)
+ pr_issue.set_labels([])
+
+ target = 'fork' if isinstance(remote_repo, remote.GitHub) else source_remote
log.info("Pushing '{}' to '{}'...".format(repository.branch, target))
if run([repository.executable(), 'push', '-f', target, repository.branch], cwd=repository.root_path).returncode:
sys.stderr.write("Failed to push '{}' to '{}' (alias of '{}')\n".format(repository.branch, target, repository.url(name=target)))
@@ -202,24 +227,13 @@
], cwd=repository.root_path).returncode:
sys.stderr.write("Failed to create and push '{}' to '{}'\n".format(history_branch, target))
- if not rmt.pull_requests:
- sys.stderr.write("'{}' cannot generate pull-requests\n".format(rmt.url))
+ if not remote_repo.pull_requests:
+ sys.stderr.write("'{}' cannot generate pull-requests\n".format(remote_repo.url))
return 1
- if args.draft and not rmt.pull_requests.SUPPORTS_DRAFTS:
- sys.stderr.write("'{}' does not support draft pull requests, aborting\n".format(rmt.url))
+ if args.draft and not remote_repo.pull_requests.SUPPORTS_DRAFTS:
+ sys.stderr.write("'{}' does not support draft pull requests, aborting\n".format(remote_repo.url))
return 1
- existing_pr = None
- for pr in rmt.pull_requests.find(opened=None, head=repository.branch):
- existing_pr = pr
- if existing_pr.opened:
- break
- if existing_pr and not existing_pr.opened and not args.defaults and (args.defaults is False or Terminal.choose(
- "'{}' is already associated with '{}', which is closed.\nWould you like to create a new pull-request?".format(
- repository.branch, existing_pr,
- ), default='No',
- ) == 'Yes'):
- existing_pr = None
commits = list(repository.commits(begin=dict(hash=branch_point.hash), end=dict(branch=repository.branch)))
issue = None
@@ -230,7 +244,7 @@
if existing_pr:
log.info("Updating pull-request for '{}'...".format(repository.branch))
- pr = rmt.pull_requests.update(
+ pr = remote_repo.pull_requests.update(
pull_request=existing_pr,
title=cls.title_for(commits),
commits=commits,
@@ -245,7 +259,7 @@
print("Updated '{}'!".format(pr))
else:
log.info("Creating pull-request for '{}'...".format(repository.branch))
- pr = rmt.pull_requests.create(
+ pr = remote_repo.pull_requests.create(
title=cls.title_for(commits),
commits=commits,
base=branch_point.branch,
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py (292537 => 292538)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py 2022-04-07 15:29:42 UTC (rev 292537)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py 2022-04-07 16:09:50 UTC (rev 292538)
@@ -394,7 +394,9 @@
)
def test_github_update(self):
- with mocks.remote.GitHub() as remote, mocks.local.Git(self.path, remote='https://{}'.format(remote.remote)) as repo, mocks.local.Svn():
+ with mocks.remote.GitHub(labels={
+ 'merging-blocked': dict(color='c005E5', description='Applied to prevent a change from being merged'),
+ }) as remote, mocks.local.Git(self.path, remote='https://{}'.format(remote.remote)) as repo, mocks.local.Svn():
with OutputCapture():
repo.staged['added.txt'] = 'added'
self.assertEqual(0, program.main(
@@ -402,6 +404,10 @@
path=self.path,
))
+ github_tracker = github.Tracker('https://{}'.format(remote.remote))
+ self.assertEqual(github_tracker.issue(1).labels, [])
+ github_tracker.issue(1).set_labels(['merging-blocked'])
+
with OutputCapture(level=logging.INFO) as captured:
repo.staged['added.txt'] = 'diff'
self.assertEqual(0, program.main(
@@ -409,6 +415,8 @@
path=self.path,
))
+ self.assertEqual(github_tracker.issue(1).labels, [])
+
self.assertEqual(
captured.stdout.getvalue(),
"Updated 'PR 1 | [Testing] Amending commits'!\n"
@@ -423,6 +431,8 @@
"Rebasing 'eng/pr-branch' on 'main'...",
"Rebased 'eng/pr-branch' on 'main!'",
" Found 1 commit...",
+ "Checking PR labels for 'merging-blocked'...",
+ "Removing 'merging-blocked' from PR 1...",
"Pushing 'eng/pr-branch' to 'fork'...",
"Syncing 'main' to remote 'fork'",
"Updating pull-request for 'eng/pr-branch'...",
@@ -460,6 +470,7 @@
"Rebased 'eng/pr-branch' on 'main!'",
' Found 1 commit...',
' Found 2 commits...',
+ "Checking PR labels for 'merging-blocked'...",
"Pushing 'eng/pr-branch' to 'fork'...",
"Syncing 'main' to remote 'fork'",
"Updating pull-request for 'eng/pr-branch'...",
@@ -503,6 +514,7 @@
"Rebasing 'eng/pr-branch' on 'main'...",
"Rebased 'eng/pr-branch' on 'main!'",
" Found 1 commit...",
+ "Checking PR labels for 'merging-blocked'...",
"Pushing 'eng/pr-branch' to 'fork'...",
"Syncing 'main' to remote 'fork'",
"Updating pull-request for 'eng/pr-branch'...",