Diff
Modified: trunk/Tools/ChangeLog (285732 => 285733)
--- trunk/Tools/ChangeLog 2021-11-12 19:02:40 UTC (rev 285732)
+++ trunk/Tools/ChangeLog 2021-11-12 19:13:03 UTC (rev 285733)
@@ -1,3 +1,23 @@
+2021-11-05 Jonathan Bedard <jbed...@apple.com>
+
+ [git-webkit] Open closed pull-request when running pr
+ https://bugs.webkit.org/show_bug.cgi?id=232765
+ <rdar://problem/85084318>
+
+ Reviewed by Dewei Zhu.
+
+ * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/bitbucket.py:
+ (BitBucket.request): Ensure displayId is set when updating PR.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py:
+ (GitHub.request): Make sure that new pull-requests are open.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
+ (PullRequest.main): Open closed pull-requests.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py:
+ (GitHub.PRGenerator.update): Only set head if user specifies head.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:
+
2021-11-12 Chris Dumez <cdu...@apple.com>
Disable MathML when in Captive Portal Mode
Modified: trunk/Tools/Scripts/libraries/webkitcorepy/setup.py (285732 => 285733)
--- trunk/Tools/Scripts/libraries/webkitcorepy/setup.py 2021-11-12 19:02:40 UTC (rev 285732)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/setup.py 2021-11-12 19:13:03 UTC (rev 285733)
@@ -30,7 +30,7 @@
setup(
name='webkitcorepy',
- version='0.11.3',
+ version='0.11.4',
description='Library containing various Python support classes and functions.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py (285732 => 285733)
--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py 2021-11-12 19:02:40 UTC (rev 285732)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py 2021-11-12 19:13:03 UTC (rev 285733)
@@ -43,7 +43,7 @@
from webkitcorepy.editor import Editor
from webkitcorepy.file_lock import FileLock
-version = Version(0, 11, 3)
+version = Version(0, 11, 4)
from webkitcorepy.autoinstall import Package, AutoInstall
if sys.version_info > (3, 0):
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/bitbucket.py (285732 => 285733)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/bitbucket.py 2021-11-12 19:02:40 UTC (rev 285732)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/bitbucket.py 2021-11-12 19:13:03 UTC (rev 285733)
@@ -221,8 +221,8 @@
json['author'] = dict(user=dict(displayName='Tim Committer', emailAddress='commit...@webkit.org'))
json['participants'] = [json['author']]
json['id'] = 1 + max([0] + [pr.get('id', 0) for pr in self.pull_requests])
- json['fromRef']['displayId'] = json['fromRef']['id'].split('/')[-2:]
- json['toRef']['displayId'] = json['toRef']['id'].split('/')[-2:]
+ json['fromRef']['displayId'] = '/'.join(json['fromRef']['id'].split('/')[-2:])
+ json['toRef']['displayId'] = '/'.join(json['toRef']['id'].split('/')[-2:])
json['state'] = 'OPEN'
json['activities'] = []
self.pull_requests.append(json)
@@ -240,6 +240,8 @@
return mocks.Response.create404(url)
if method == 'PUT':
self.pull_requests[existing].update(json)
+ self.pull_requests[existing]['fromRef']['displayId'] = '/'.join(json['fromRef']['id'].split('/')[-2:])
+ self.pull_requests[existing]['toRef']['displayId'] = '/'.join(json['toRef']['id'].split('/')[-2:])
if len(split_url) < 11:
return mocks.Response.fromJson({key: value for key, value in self.pull_requests[existing].items() if key != 'activities'})
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py (285732 => 285733)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py 2021-11-12 19:02:40 UTC (rev 285732)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py 2021-11-12 19:13:03 UTC (rev 285733)
@@ -408,6 +408,7 @@
# Create specifically
if method == 'POST' and auth and stripped_url == pr_base:
pr['number'] = 1 + max([0] + [pr.get('number', 0) for pr in self.pull_requests])
+ pr['state'] = 'open'
pr['user'] = dict(login=auth.username)
pr['_links'] = dict(issue=dict(href=''.format(self.api_remote, pr['number'])))
self.pull_requests.append(pr)
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py (285732 => 285733)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py 2021-11-12 19:02:40 UTC (rev 285732)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py 2021-11-12 19:13:03 UTC (rev 285733)
@@ -26,7 +26,7 @@
from .command import Command
from .branch import Branch
-from webkitcorepy import arguments, run
+from webkitcorepy import arguments, run, Terminal
from webkitscmpy import local, log, remote
@@ -50,6 +50,10 @@
help='Rebase (or do not rebase) the pull-request on the source branch before pushing',
action=""
)
+ parser.add_argument(
+ '--defaults', '--no-defaults', action="" default=None,
+ help='Do not prompt the user for defaults, always use (or do not use) them',
+ )
@classmethod
def create_commit(cls, args, repository, **kwargs):
@@ -130,17 +134,28 @@
if not rmt.pull_requests:
sys.stderr.write("'{}' cannot generate pull-requests\n".format(rmt.url))
return 1
- candidates = list(rmt.pull_requests.find(opened=None, head=repository.branch))
+ existing_pr = None
+ for pr in rmt.pull_requests.find(opened=None, head=repository.branch):
+ existing_pr = pr
+ if existing_pr.opened:
+ continue
+ 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)))
- if candidates:
+ if existing_pr:
log.warning("Updating pull-request for '{}'...".format(repository.branch))
pr = rmt.pull_requests.update(
- pull_request=candidates[0],
+ pull_request=existing_pr,
title=cls.title_for(commits),
commits=commits,
base=branch_point.branch,
head=repository.branch,
+ opened=None if existing_pr.opened else True
)
if not pr:
sys.stderr.write("Failed to update pull-request '{}'\n".format(candidates[0]))
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py (285732 => 285733)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py 2021-11-12 19:02:40 UTC (rev 285732)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py 2021-11-12 19:13:03 UTC (rev 285733)
@@ -127,8 +127,9 @@
updates = dict(
title=title or pull_request.title,
base=base or pull_request.base,
- head='{}:{}'.format(user, head) if head else pull_request.head,
)
+ if head:
+ updates['head'] = '{}:{}'.format(user, head)
if body or commits:
updates['body'] = PullRequest.create_body(body, commits)
if opened is not None:
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py (285732 => 285733)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py 2021-11-12 19:02:40 UTC (rev 285732)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py 2021-11-12 19:13:03 UTC (rev 285733)
@@ -25,7 +25,8 @@
import unittest
from webkitcorepy import OutputCapture, testing
-from webkitscmpy import Contributor, Commit, PullRequest, program, mocks, remote
+from webkitcorepy.mocks import Terminal as MockTerminal
+from webkitscmpy import Contributor, Commit, PullRequest, local, program, mocks, remote
class TestPullRequest(unittest.TestCase):
@@ -145,7 +146,6 @@
self.assertEqual(commits[1].message, '[scoping] Bug to fix (Part 1)\n\nReviewed by Tim Contributor.')
def test_parse_html_body_multiple(self):
- self.maxDiff = None
body, commits = PullRequest.parse_body('''#### 11aa76f9fc380e9fe06157154f32b304e8dc4749
<pre>
[scoping] Bug to fix (Part 2)
@@ -358,7 +358,6 @@
self.assertEqual(captured.stderr.getvalue(), '')
log = captured.root.log.getvalue().splitlines()
- self.maxDiff = None
self.assertEqual(
[line for line in log if 'Mock process' not in line], [
"Amending commit...",
@@ -372,6 +371,42 @@
],
)
+ def test_github_reopen(self):
+ with mocks.remote.GitHub() 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(
+ args=('pull-request', '-i', 'pr-branch'),
+ path=self.path,
+ ))
+
+ local.Git(self.path).remote().pull_requests.get(1).close()
+ self.assertFalse(local.Git(self.path).remote().pull_requests.get(1).opened)
+
+ with OutputCapture() as captured, MockTerminal.input('n'):
+ repo.staged['added.txt'] = 'diff'
+ self.assertEqual(0, program.main(
+ args=('pull-request',),
+ path=self.path,
+ ))
+
+ self.assertTrue(local.Git(self.path).remote().pull_requests.get(1).opened)
+
+ self.assertEqual(captured.stderr.getvalue(), '')
+ log = captured.root.log.getvalue().splitlines()
+ self.assertEqual(
+ [line for line in log if 'Mock process' not in line], [
+ "Amending commit...",
+ ' Found 1 commit...',
+ "Rebasing 'eng/pr-branch' on 'main'...",
+ "Rebased 'eng/pr-branch' on 'main!'",
+ " Found 1 commit...",
+ "Pushing 'eng/pr-branch' to 'fork'...",
+ "Updating pull-request for 'eng/pr-branch'...",
+ "Updated 'PR 1 | Amended commit'!",
+ ],
+ )
+
def test_bitbucket(self):
with OutputCapture() as captured, mocks.remote.BitBucket() as remote, mocks.local.Git(self.path, remote='ssh://git@{}/{}/{}.git'.format(
remote.hosts[0], remote.project.split('/')[1], remote.project.split('/')[3],
@@ -432,7 +467,45 @@
],
)
+ def test_bitbucket_reopen(self):
+ with mocks.remote.BitBucket() as remote, mocks.local.Git(self.path, remote='ssh://git@{}/{}/{}.git'.format(
+ remote.hosts[0], remote.project.split('/')[1], remote.project.split('/')[3],
+ )) as repo, mocks.local.Svn():
+ with OutputCapture():
+ repo.staged['added.txt'] = 'added'
+ self.assertEqual(0, program.main(
+ args=('pull-request', '-i', 'pr-branch'),
+ path=self.path,
+ ))
+ local.Git(self.path).remote().pull_requests.get(1).close()
+ self.assertFalse(local.Git(self.path).remote().pull_requests.get(1).opened)
+
+ with OutputCapture() as captured, MockTerminal.input('n'):
+ repo.staged['added.txt'] = 'diff'
+ self.assertEqual(0, program.main(
+ args=('pull-request',),
+ path=self.path,
+ ))
+
+ self.assertTrue(local.Git(self.path).remote().pull_requests.get(1).opened)
+
+ self.assertEqual(captured.stderr.getvalue(), '')
+ log = captured.root.log.getvalue().splitlines()
+ self.assertEqual(
+ [line for line in log if 'Mock process' not in line], [
+ "Amending commit...",
+ ' Found 1 commit...',
+ "Rebasing 'eng/pr-branch' on 'main'...",
+ "Rebased 'eng/pr-branch' on 'main!'",
+ " Found 1 commit...",
+ "Pushing 'eng/pr-branch' to 'origin'...",
+ "Updating pull-request for 'eng/pr-branch'...",
+ "Updated 'PR 1 | Amended commit'!",
+ ],
+ )
+
+
class TestNetworkPullRequestGitHub(unittest.TestCase):
remote = 'https://github.example.com/WebKit/WebKit'