Changeset 285890 in webkit
- Timestamp:
- Nov 16, 2021, 2:55:52 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py (modified) (10 diffs)
-
Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py (modified) (1 diff)
-
Scripts/libraries/webkitscmpy/webkitscmpy/test/land_unittest.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r285877 r285890 1 2021-11-12 Jonathan Bedard <jbedard@apple.com> 2 3 [git-webkit] Mark landed changes as merged 4 https://bugs.webkit.org/show_bug.cgi?id=233056 5 <rdar://problem/85351564> 6 7 Reviewed by Dewei Zhu. 8 9 For BitBucket and GitHub to recognize a pull-request as merged, the target 10 branch must be updated with the exact commit to be merged as the merge occurs. 11 12 * Scripts/libraries/webkitscmpy/setup.py: Bump version. 13 * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto. 14 * Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py: 15 (Land.main): Update source branch when merging commits to target branch. 16 * Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py: 17 (BitBucket.PRGenerator.update): Only delete values if they exist. 18 * Scripts/libraries/webkitscmpy/webkitscmpy/test/land_unittest.py: 19 (TestLand): 20 (TestLandGitHub): 21 (TestLandBitBucket): 22 1 23 2021-11-16 Chris Dumez <cdumez@apple.com> 2 24 -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py
r285272 r285890 28 28 from .command import Command 29 29 from .branch import Branch 30 from .pull_request import PullRequest 30 31 from argparse import Namespace 31 32 from webkitcorepy import arguments, run, string_utils, Terminal 32 from webkitscmpy import local, log 33 from webkitscmpy import local, log, remote 33 34 34 35 … … 76 77 return 1 77 78 78 if not Branch.editable(repository.branch, repository=repository): 79 source_branch = repository.branch 80 if not Branch.editable(source_branch, repository=repository): 79 81 sys.stderr.write("Can only 'land' editable branches\n") 80 82 return 1 81 83 branch_point = Branch.branch_point(repository) 82 commits = list(repository.commits(begin=dict(hash=branch_point.hash), end=dict(branch= repository.branch)))84 commits = list(repository.commits(begin=dict(hash=branch_point.hash), end=dict(branch=source_branch))) 83 85 if not commits: 84 86 sys.stderr.write('Failed to find commits to land\n') … … 88 90 rmt = repository.remote() 89 91 if rmt and rmt.pull_requests: 90 candidates = list(rmt.pull_requests.find(opened=True, head= repository.branch))92 candidates = list(rmt.pull_requests.find(opened=True, head=source_branch)) 91 93 if len(candidates) == 1: 92 94 pull_request = candidates[0] 93 95 elif candidates: 94 sys.stderr.write("Multiple pull-request match '{}'\n".format( repository.branch))96 sys.stderr.write("Multiple pull-request match '{}'\n".format(source_branch)) 95 97 96 98 if pull_request and args.review: … … 119 121 date='{} -{}'.format(int(time.time()), repository.gmtoffset()) 120 122 ), '--msg-filter', 'sed "s/NOBODY (OO*PP*S!*)/{}/g"'.format(string_utils.join([p.name for p in pull_request.approvers])), 121 '{}...{}'.format( repository.branch, branch_point.hash),123 '{}...{}'.format(source_branch, branch_point.hash), 122 124 ], cwd=repository.root_path, env={'FILTER_BRANCH_SQUELCH_WARNING': '1'}, capture_output=True).returncode: 123 125 sys.stderr.write('Failed to set reviewers\n') 124 126 return 1 125 commits = list(repository.commits(begin=dict(hash=branch_point.hash), end=dict(branch= repository.branch)))127 commits = list(repository.commits(begin=dict(hash=branch_point.hash), end=dict(branch=source_branch))) 126 128 if not commits: 127 129 sys.stderr.write('Failed to find commits after setting reviewers\n') … … 129 131 130 132 elif not pull_request: 131 sys.stderr.write("Failed to find pull-request associated with '{}'\n".format( repository.branch))133 sys.stderr.write("Failed to find pull-request associated with '{}'\n".format(source_branch)) 132 134 133 135 if not args.oops and any([cls.OOPS_RE.search(commit.message) for commit in commits]): … … 136 138 137 139 if not args.oops: 138 for line in repository.diff_lines(branch_point.hash, repository.branch):140 for line in repository.diff_lines(branch_point.hash, source_branch): 139 141 if cls.OOPS_RE.search(line): 140 142 sys.stderr.write("Found '(OOPS!)' in commit diff, please resolve before committing\n") … … 142 144 143 145 target = pull_request.base if pull_request else branch_point.branch 144 log.warning("Rebasing '{}' from '{}' to '{}'...".format( repository.branch, branch_point.branch, target))146 log.warning("Rebasing '{}' from '{}' to '{}'...".format(source_branch, branch_point.branch, target)) 145 147 if repository.fetch(branch=target, remote=cls.REMOTE): 146 148 sys.stderr.write("Failed to fetch '{}' from '{}'\n".format(target, cls.REMOTE)) 147 149 return 1 148 if repository.rebase(target=target, base=branch_point.branch, head= repository.branch):149 sys.stderr.write("Failed to rebase '{}' onto '{}', please resolve conflicts\n".format( repository.branch, target))150 return 1 151 log.warning("Rebased '{}' from '{}' to '{}'!".format( repository.branch, branch_point.branch, target))152 153 if run([repository.executable(), 'branch', '-f', target, repository.branch], cwd=repository.root_path).returncode:150 if repository.rebase(target=target, base=branch_point.branch, head=source_branch): 151 sys.stderr.write("Failed to rebase '{}' onto '{}', please resolve conflicts\n".format(source_branch, target)) 152 return 1 153 log.warning("Rebased '{}' from '{}' to '{}'!".format(source_branch, branch_point.branch, target)) 154 155 if run([repository.executable(), 'branch', '-f', target, source_branch], cwd=repository.root_path).returncode: 154 156 sys.stderr.write("Failed to move '{}' ref\n".format(target)) 155 157 return 1 156 158 157 159 if identifier_template: 158 source = repository.branch159 160 repository.checkout(target) 160 161 if Canonicalize.main(Namespace( … … 163 164 sys.stderr.write("Failed to embed identifiers to '{}'\n".format(target)) 164 165 return 1 165 if run([repository.executable(), 'branch', '-f', source , target], cwd=repository.root_path).returncode:166 if run([repository.executable(), 'branch', '-f', source_branch, target], cwd=repository.root_path).returncode: 166 167 sys.stderr.write("Failed to move '{}' ref to the canonicalized head of '{}'\n".format(source, target)) 167 168 return -1 169 170 # Need to compute the remote source 171 remote_target = 'fork' if isinstance(rmt, remote.GitHub) else 'origin' 168 172 169 173 if canonical_svn: … … 182 186 while original.hash == latest.hash: 183 187 if time.time() - started > cls.MIRROR_TIMEOUT: 184 sys.stderr.write("Timed out waiting for the git-svn mirror, '{}' landed but not closed\n".format(pull_request or repository.branch))188 sys.stderr.write("Timed out waiting for the git-svn mirror, '{}' landed but not closed\n".format(pull_request or source_branch)) 185 189 return 1 186 190 log.warning(' Verifying mirror processesed change') 187 191 time.sleep(5) 188 192 run([repository.executable(), 'pull'], cwd=repository.root_path) 189 original = repository.find('HEAD', include_log=False, include_identifier=False) 193 latest = repository.find('HEAD', include_log=False, include_identifier=False) 194 if pull_request: 195 run([repository.executable(), 'branch', '-f', source_branch, target], cwd=repository.root_path) 196 commits = list(repository.commits(begin=dict(argument='{}~{}'.format(source_branch, len(commits))), end=dict(branch=source_branch))) 197 run([repository.executable(), 'push', '-f', remote_target, source_branch], cwd=repository.root_path) 198 rmt.pull_requests.update( 199 pull_request=pull_request, 200 title=PullRequest.title_for(commits), 201 commits=commits, 202 base=branch_point.branch, 203 head=source_branch, 204 ) 190 205 191 206 else: 207 if pull_request: 208 log.warning("Updating '{}' to match landing commits...".format(pull_request)) 209 commits = list(repository.commits(begin=dict(argument='{}~{}'.format(source_branch, len(commits))), end=dict(branch=source_branch))) 210 run([repository.executable(), 'push', '-f', remote_target, source_branch], cwd=repository.root_path) 211 rmt.pull_requests.update( 212 pull_request=pull_request, 213 title=PullRequest.title_for(commits), 214 commits=commits, 215 base=branch_point.branch, 216 head=source_branch, 217 ) 218 192 219 if run([repository.executable(), 'push', cls.REMOTE, target], cwd=repository.root_path).returncode: 193 220 sys.stderr.write("Failed to push '{}' to '{}'\n".format(target, cls.REMOTE)) 194 221 return 1 222 repository.checkout(target) 195 223 196 224 commit = repository.commit(branch=target, include_log=False) … … 203 231 if pull_request: 204 232 pull_request.comment(land_message) 205 pull_request.close() 206 233 234 if args.defaults or Terminal.choose("Delete branch '{}'?".format(source_branch), default='Yes') == 'Yes': 235 run([repository.executable(), 'branch', '-D', source_branch], cwd=repository.root_path) 236 run([repository.executable(), 'push', remote_target, '--delete', source_branch], cwd=repository.root_path) 207 237 return 0 -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/bitbucket.py
r284892 r285890 203 203 return None 204 204 data = response.json() 205 d el data['author']206 d el data['participants']205 data.pop('author', None) 206 data.pop('participants', None) 207 207 data.update(to_change) 208 208 -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/land_unittest.py
r285272 r285890 91 91 92 92 def test_default(self): 93 with OutputCapture() as captured, repository(self.path, has_oops=False), mocks.local.Svn() :93 with OutputCapture() as captured, repository(self.path, has_oops=False), mocks.local.Svn(), MockTerminal.input('n'): 94 94 self.assertEqual(0, program.main( 95 95 args=('land',), … … 110 110 "Failed to find pull-request associated with 'eng/example'\n", 111 111 ) 112 self.assertEqual(captured.stdout.getvalue(), 'Landed a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd!\n') 112 self.assertEqual( 113 captured.stdout.getvalue(), 114 'Landed a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd!\n' 115 "Delete branch 'eng/example'? (Yes/No): \n", 116 ) 113 117 114 118 def test_canonicalize(self): 115 with OutputCapture() as captured, repository(self.path, has_oops=False), mocks.local.Svn() :119 with OutputCapture() as captured, repository(self.path, has_oops=False), mocks.local.Svn(), MockTerminal.input('n'): 116 120 self.assertEqual(0, program.main( 117 121 args=('land',), … … 146 150 'Rewrite a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd (1/1) (--- seconds passed, remaining --- predicted)\n' 147 151 '1 commit successfully canonicalized!\n' 148 'Landed https://commits.webkit.org/6@main (a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd)!\n', 152 'Landed https://commits.webkit.org/6@main (a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd)!\n' 153 "Delete branch 'eng/example'? (Yes/No): \n", 149 154 ) 150 155 … … 164 169 165 170 def test_svn(self): 166 self.maxDiff = None 167 with MockTime, OutputCapture() as captured, repository(self.path, has_oops=False, git_svn=True), mocks.local.Svn(): 171 with MockTime, OutputCapture() as captured, repository(self.path, has_oops=False, git_svn=True), mocks.local.Svn(), MockTerminal.input('n'): 168 172 self.assertEqual(0, program.main( 169 173 args=('land',), … … 187 191 self.assertEqual( 188 192 captured.stdout.getvalue(), 189 'Landed a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd!\n', 193 'Landed a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd!\n' 194 "Delete branch 'eng/example'? (Yes/No): \n", 190 195 ) 191 196 … … 282 287 283 288 def test_insert_review(self): 284 with OutputCapture() as captured, MockTerminal.input('y' ), self.webserver(approved=True) as remote, \289 with OutputCapture() as captured, MockTerminal.input('y', 'n'), self.webserver(approved=True) as remote, \ 285 290 repository(self.path, has_oops=True, remote='https://{}'.format(remote.remote)), mocks.local.Svn(): 286 291 self.assertEqual(0, program.main( … … 303 308 "Rebasing 'eng/example' from 'main' to 'main'...", 304 309 "Rebased 'eng/example' from 'main' to 'main'!", 310 "Updating 'PR 1 | Example Change' to match landing commits...", 305 311 ], 306 312 ) … … 309 315 captured.stdout.getvalue(), 310 316 "Set 'Ricky Reviewer' as your reviewer? (Yes/No): \n" 311 'Landed a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd!\n', 317 'Landed a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd!\n' 318 "Delete branch 'eng/example'? (Yes/No): \n", 312 319 ) 313 320 … … 407 414 408 415 def test_insert_review(self): 409 with OutputCapture() as captured, MockTerminal.input('y' ), self.webserver(approved=True) as remote, repository(416 with OutputCapture() as captured, MockTerminal.input('y', 'n'), self.webserver(approved=True) as remote, repository( 410 417 self.path, has_oops=True, remote='ssh://git@{}/{}/{}.git'.format( 411 418 remote.hosts[0], remote.project.split('/')[1], remote.project.split('/')[3], … … 430 437 "Rebasing 'eng/example' from 'main' to 'main'...", 431 438 "Rebased 'eng/example' from 'main' to 'main'!", 439 "Updating 'PR 1 | Example Change' to match landing commits...", 432 440 ], 433 441 ) … … 436 444 captured.stdout.getvalue(), 437 445 "Set 'Ricky Reviewer' as your reviewer? (Yes/No): \n" 438 'Landed a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd!\n', 439 ) 446 'Landed a5fe8afe9bf7d07158fcd9e9732ff02a712db2fd!\n' 447 "Delete branch 'eng/example'? (Yes/No): \n", 448 )
Note:
See TracChangeset
for help on using the changeset viewer.