Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (289658 => 289659)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-02-11 20:19:40 UTC (rev 289658)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-02-11 20:25:34 UTC (rev 289659)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(4, 1, 1)
+version = Version(4, 1, 2)
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 (289658 => 289659)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py 2022-02-11 20:19:40 UTC (rev 289658)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py 2022-02-11 20:25:34 UTC (rev 289659)
@@ -1,4 +1,4 @@
-# Copyright (C) 2021 Apple Inc. All rights reserved.
+# Copyright (C) 2021-2022 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -138,11 +138,21 @@
sys.stderr.write("Creating a pull-request for '{}' but we're on '{}'\n".format(args.issue, repository.branch))
return 1
+ # FIXME: Source remote will not always be origin
+ source_remote = 'origin'
+ branch_point = Branch.branch_point(repository)
+ if run([
+ repository.executable(), 'branch', '-f',
+ branch_point.branch,
+ 'remotes/{}/{}'.format(source_remote, branch_point.branch),
+ ], cwd=repository.root_path).returncode:
+ sys.stderr.write("Failed to match '{}' to it's remote '{}'\n".format(branch_point.branch, source_remote))
+ return 1
+
result = cls.create_commit(args, repository, **kwargs)
if result:
return result
- branch_point = Branch.branch_point(repository)
if args.rebase or (args.rebase is None and repository.config().get('pull.rebase')):
log.info("Rebasing '{}' on '{}'...".format(repository.branch, branch_point.branch))
if repository.pull(rebase=True, branch=branch_point.branch):
@@ -150,12 +160,14 @@
return 1
log.info("Rebased '{}' on '{}!'".format(repository.branch, branch_point.branch))
branch_point = Branch.branch_point(repository)
+ else:
+ branch_point = Branch.branch_point(repository)
- rmt = repository.remote()
+ rmt = repository.remote(name=source_remote)
if not rmt:
sys.stderr.write("'{}' doesn't have a recognized remote\n".format(repository.root_path))
return 1
- target = 'fork' if isinstance(rmt, remote.GitHub) else 'origin'
+ target = 'fork' if isinstance(rmt, 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)))
@@ -163,7 +175,7 @@
sys.stderr.write("your checkout may not have permission to push to '{}'\n".format(repository.url(name=target)))
return 1
- if args.history or (target != 'origin' and args.history is None and args.technique == 'overwrite'):
+ if args.history or (target != source_remote and args.history is None and args.technique == 'overwrite'):
regex = re.compile(r'^{}-(?P<count>\d+)$'.format(repository.branch))
count = max([
int(regex.match(branch).group('count')) if regex.match(branch) else 0 for branch in
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py (289658 => 289659)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py 2022-02-11 20:19:40 UTC (rev 289658)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py 2022-02-11 20:25:34 UTC (rev 289659)
@@ -271,7 +271,7 @@
args=('pull-request', '-i', 'pr-branch', '-v'),
path=self.path,
))
- self.assertEqual(captured.root.log.getvalue(), "Creating the local development branch 'eng/pr-branch'...\n")
+ self.assertEqual(captured.root.log.getvalue(), "Creating the local development branch 'eng/pr-branch'...\n Found 1 commit...\n")
self.assertEqual(captured.stderr.getvalue(), 'No modified files\n')
def test_staged(self):
@@ -287,8 +287,8 @@
self.assertEqual(
'\n'.join([line for line in captured.root.log.getvalue().splitlines() if 'Mock process' not in line]),
"""Creating the local development branch 'eng/pr-branch'...
+ Found 1 commit...
Creating commit...
- Found 1 commit...
Rebasing 'eng/pr-branch' on 'main'...
Rebased 'eng/pr-branch' on 'main!'
Found 1 commit...""")
@@ -310,9 +310,9 @@
self.assertEqual(
'\n'.join([line for line in captured.root.log.getvalue().splitlines() if 'Mock process' not in line]),
"""Creating the local development branch 'eng/pr-branch'...
+ Found 1 commit...
Adding modified.txt...
Creating commit...
- Found 1 commit...
Rebasing 'eng/pr-branch' on 'main'...
Rebased 'eng/pr-branch' on 'main!'
Found 1 commit...""")
@@ -338,8 +338,8 @@
self.assertEqual(
[line for line in log if 'Mock process' not in line], [
"Creating the local development branch 'eng/pr-branch'...",
+ ' Found 1 commit...',
'Creating commit...',
- ' Found 1 commit...',
"Rebasing 'eng/pr-branch' on 'main'...",
"Rebased 'eng/pr-branch' on 'main!'",
" Found 1 commit...",
@@ -373,8 +373,8 @@
log = captured.root.log.getvalue().splitlines()
self.assertEqual(
[line for line in log if 'Mock process' not in line], [
+ ' Found 1 commit...',
"Amending commit...",
- ' Found 1 commit...',
"Rebasing 'eng/pr-branch' on 'main'...",
"Rebased 'eng/pr-branch' on 'main!'",
" Found 1 commit...",
@@ -408,9 +408,8 @@
log = captured.root.log.getvalue().splitlines()
self.assertEqual(
[line for line in log if 'Mock process' not in line], [
- "Creating commit...",
' Found 1 commit...',
- ' Found 2 commits...',
+ 'Creating commit...',
"Rebasing 'eng/pr-branch' on 'main'...",
"Rebased 'eng/pr-branch' on 'main!'",
' Found 1 commit...',
@@ -452,8 +451,8 @@
log = captured.root.log.getvalue().splitlines()
self.assertEqual(
[line for line in log if 'Mock process' not in line], [
+ ' Found 1 commit...',
"Amending commit...",
- ' Found 1 commit...',
"Rebasing 'eng/pr-branch' on 'main'...",
"Rebased 'eng/pr-branch' on 'main!'",
" Found 1 commit...",
@@ -484,8 +483,8 @@
self.assertEqual(
[line for line in log if 'Mock process' not in line], [
"Creating the local development branch 'eng/pr-branch'...",
+ ' Found 1 commit...',
'Creating commit...',
- ' Found 1 commit...',
"Rebasing 'eng/pr-branch' on 'main'...",
"Rebased 'eng/pr-branch' on 'main!'",
" Found 1 commit...",
@@ -521,8 +520,8 @@
log = captured.root.log.getvalue().splitlines()
self.assertEqual(
[line for line in log if 'Mock process' not in line], [
+ ' Found 1 commit...',
"Amending commit...",
- ' Found 1 commit...',
"Rebasing 'eng/pr-branch' on 'main'...",
"Rebased 'eng/pr-branch' on 'main!'",
" Found 1 commit...",
@@ -558,9 +557,8 @@
log = captured.root.log.getvalue().splitlines()
self.assertEqual(
[line for line in log if 'Mock process' not in line], [
- "Creating commit...",
' Found 1 commit...',
- ' Found 2 commits...',
+ 'Creating commit...',
"Rebasing 'eng/pr-branch' on 'main'...",
"Rebased 'eng/pr-branch' on 'main!'",
' Found 1 commit...',
@@ -604,8 +602,8 @@
log = captured.root.log.getvalue().splitlines()
self.assertEqual(
[line for line in log if 'Mock process' not in line], [
+ ' Found 1 commit...',
"Amending commit...",
- ' Found 1 commit...',
"Rebasing 'eng/pr-branch' on 'main'...",
"Rebased 'eng/pr-branch' on 'main!'",
" Found 1 commit...",