Changeset 285733 in webkit
- Timestamp:
- Nov 12, 2021, 11:13:03 AM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 8 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/libraries/webkitcorepy/setup.py (modified) (1 diff)
-
Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py (modified) (1 diff)
-
Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/bitbucket.py (modified) (2 diffs)
-
Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py (modified) (1 diff)
-
Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py (modified) (3 diffs)
-
Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py (modified) (1 diff)
-
Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r285731 r285733 1 2021-11-05 Jonathan Bedard <jbedard@apple.com> 2 3 [git-webkit] Open closed pull-request when running pr 4 https://bugs.webkit.org/show_bug.cgi?id=232765 5 <rdar://problem/85084318> 6 7 Reviewed by Dewei Zhu. 8 9 * Scripts/libraries/webkitscmpy/setup.py: Bump version. 10 * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto. 11 * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/bitbucket.py: 12 (BitBucket.request): Ensure displayId is set when updating PR. 13 * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py: 14 (GitHub.request): Make sure that new pull-requests are open. 15 * Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py: 16 (PullRequest.main): Open closed pull-requests. 17 * Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py: 18 (GitHub.PRGenerator.update): Only set head if user specifies head. 19 * Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py: 20 1 21 2021-11-12 Chris Dumez <cdumez@apple.com> 2 22 -
trunk/Tools/Scripts/libraries/webkitcorepy/setup.py
r283843 r285733 31 31 setup( 32 32 name='webkitcorepy', 33 version='0.11. 3',33 version='0.11.4', 34 34 description='Library containing various Python support classes and functions.', 35 35 long_description=readme(), -
trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py
r283843 r285733 44 44 from webkitcorepy.file_lock import FileLock 45 45 46 version = Version(0, 11, 3)46 version = Version(0, 11, 4) 47 47 48 48 from webkitcorepy.autoinstall import Package, AutoInstall -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/bitbucket.py
r284892 r285733 222 222 json['participants'] = [json['author']] 223 223 json['id'] = 1 + max([0] + [pr.get('id', 0) for pr in self.pull_requests]) 224 json['fromRef']['displayId'] = json['fromRef']['id'].split('/')[-2:]225 json['toRef']['displayId'] = json['toRef']['id'].split('/')[-2:]224 json['fromRef']['displayId'] = '/'.join(json['fromRef']['id'].split('/')[-2:]) 225 json['toRef']['displayId'] = '/'.join(json['toRef']['id'].split('/')[-2:]) 226 226 json['state'] = 'OPEN' 227 227 json['activities'] = [] … … 241 241 if method == 'PUT': 242 242 self.pull_requests[existing].update(json) 243 self.pull_requests[existing]['fromRef']['displayId'] = '/'.join(json['fromRef']['id'].split('/')[-2:]) 244 self.pull_requests[existing]['toRef']['displayId'] = '/'.join(json['toRef']['id'].split('/')[-2:]) 243 245 if len(split_url) < 11: 244 246 return mocks.Response.fromJson({key: value for key, value in self.pull_requests[existing].items() if key != 'activities'}) -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/git_hub.py
r285035 r285733 409 409 if method == 'POST' and auth and stripped_url == pr_base: 410 410 pr['number'] = 1 + max([0] + [pr.get('number', 0) for pr in self.pull_requests]) 411 pr['state'] = 'open' 411 412 pr['user'] = dict(login=auth.username) 412 413 pr['_links'] = dict(issue=dict(href='https://{}/issues/{}'.format(self.api_remote, pr['number']))) -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py
r285158 r285733 27 27 from .branch import Branch 28 28 29 from webkitcorepy import arguments, run 29 from webkitcorepy import arguments, run, Terminal 30 30 from webkitscmpy import local, log, remote 31 31 … … 50 50 help='Rebase (or do not rebase) the pull-request on the source branch before pushing', 51 51 action=arguments.NoAction, 52 ) 53 parser.add_argument( 54 '--defaults', '--no-defaults', action=arguments.NoAction, default=None, 55 help='Do not prompt the user for defaults, always use (or do not use) them', 52 56 ) 53 57 … … 131 135 sys.stderr.write("'{}' cannot generate pull-requests\n".format(rmt.url)) 132 136 return 1 133 candidates = list(rmt.pull_requests.find(opened=None, head=repository.branch)) 137 existing_pr = None 138 for pr in rmt.pull_requests.find(opened=None, head=repository.branch): 139 existing_pr = pr 140 if existing_pr.opened: 141 continue 142 if existing_pr and not existing_pr.opened and not args.defaults and (args.defaults is False or Terminal.choose( 143 "'{}' is already associated with '{}', which is closed.\nWould you like to create a new pull-request?".format( 144 repository.branch, existing_pr, 145 ), default='No', 146 ) == 'Yes'): 147 existing_pr = None 134 148 commits = list(repository.commits(begin=dict(hash=branch_point.hash), end=dict(branch=repository.branch))) 135 149 136 if candidates:150 if existing_pr: 137 151 log.warning("Updating pull-request for '{}'...".format(repository.branch)) 138 152 pr = rmt.pull_requests.update( 139 pull_request= candidates[0],153 pull_request=existing_pr, 140 154 title=cls.title_for(commits), 141 155 commits=commits, 142 156 base=branch_point.branch, 143 157 head=repository.branch, 158 opened=None if existing_pr.opened else True 144 159 ) 145 160 if not pr: -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py
r285142 r285733 128 128 title=title or pull_request.title, 129 129 base=base or pull_request.base, 130 head='{}:{}'.format(user, head) if head else pull_request.head, 131 ) 130 ) 131 if head: 132 updates['head'] = '{}:{}'.format(user, head) 132 133 if body or commits: 133 134 updates['body'] = PullRequest.create_body(body, commits) -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py
r285142 r285733 26 26 27 27 from webkitcorepy import OutputCapture, testing 28 from webkitscmpy import Contributor, Commit, PullRequest, program, mocks, remote 28 from webkitcorepy.mocks import Terminal as MockTerminal 29 from webkitscmpy import Contributor, Commit, PullRequest, local, program, mocks, remote 29 30 30 31 … … 146 147 147 148 def test_parse_html_body_multiple(self): 148 self.maxDiff = None149 149 body, commits = PullRequest.parse_body('''#### 11aa76f9fc380e9fe06157154f32b304e8dc4749 150 150 <pre> … … 359 359 self.assertEqual(captured.stderr.getvalue(), '') 360 360 log = captured.root.log.getvalue().splitlines() 361 self.maxDiff = None 361 self.assertEqual( 362 [line for line in log if 'Mock process' not in line], [ 363 "Amending commit...", 364 ' Found 1 commit...', 365 "Rebasing 'eng/pr-branch' on 'main'...", 366 "Rebased 'eng/pr-branch' on 'main!'", 367 " Found 1 commit...", 368 "Pushing 'eng/pr-branch' to 'fork'...", 369 "Updating pull-request for 'eng/pr-branch'...", 370 "Updated 'PR 1 | Amended commit'!", 371 ], 372 ) 373 374 def test_github_reopen(self): 375 with mocks.remote.GitHub() as remote, mocks.local.Git(self.path, remote='https://{}'.format(remote.remote)) as repo, mocks.local.Svn(): 376 with OutputCapture(): 377 repo.staged['added.txt'] = 'added' 378 self.assertEqual(0, program.main( 379 args=('pull-request', '-i', 'pr-branch'), 380 path=self.path, 381 )) 382 383 local.Git(self.path).remote().pull_requests.get(1).close() 384 self.assertFalse(local.Git(self.path).remote().pull_requests.get(1).opened) 385 386 with OutputCapture() as captured, MockTerminal.input('n'): 387 repo.staged['added.txt'] = 'diff' 388 self.assertEqual(0, program.main( 389 args=('pull-request',), 390 path=self.path, 391 )) 392 393 self.assertTrue(local.Git(self.path).remote().pull_requests.get(1).opened) 394 395 self.assertEqual(captured.stderr.getvalue(), '') 396 log = captured.root.log.getvalue().splitlines() 362 397 self.assertEqual( 363 398 [line for line in log if 'Mock process' not in line], [ … … 417 452 path=self.path, 418 453 )) 454 455 self.assertEqual(captured.stderr.getvalue(), '') 456 log = captured.root.log.getvalue().splitlines() 457 self.assertEqual( 458 [line for line in log if 'Mock process' not in line], [ 459 "Amending commit...", 460 ' Found 1 commit...', 461 "Rebasing 'eng/pr-branch' on 'main'...", 462 "Rebased 'eng/pr-branch' on 'main!'", 463 " Found 1 commit...", 464 "Pushing 'eng/pr-branch' to 'origin'...", 465 "Updating pull-request for 'eng/pr-branch'...", 466 "Updated 'PR 1 | Amended commit'!", 467 ], 468 ) 469 470 def test_bitbucket_reopen(self): 471 with mocks.remote.BitBucket() as remote, mocks.local.Git(self.path, remote='ssh://git@{}/{}/{}.git'.format( 472 remote.hosts[0], remote.project.split('/')[1], remote.project.split('/')[3], 473 )) as repo, mocks.local.Svn(): 474 with OutputCapture(): 475 repo.staged['added.txt'] = 'added' 476 self.assertEqual(0, program.main( 477 args=('pull-request', '-i', 'pr-branch'), 478 path=self.path, 479 )) 480 481 local.Git(self.path).remote().pull_requests.get(1).close() 482 self.assertFalse(local.Git(self.path).remote().pull_requests.get(1).opened) 483 484 with OutputCapture() as captured, MockTerminal.input('n'): 485 repo.staged['added.txt'] = 'diff' 486 self.assertEqual(0, program.main( 487 args=('pull-request',), 488 path=self.path, 489 )) 490 491 self.assertTrue(local.Git(self.path).remote().pull_requests.get(1).opened) 419 492 420 493 self.assertEqual(captured.stderr.getvalue(), '')
Note:
See TracChangeset
for help on using the changeset viewer.