Skip to content

Commit

Permalink
Cherry-pick 263431@main (2a1e05d). rdar://108565576
Browse files Browse the repository at this point in the history
    [git-webkit] Fallback to git push if API call fails
    https://bugs.webkit.org/show_bug.cgi?id=255999
    rdar://108565576

    Reviewed by Aakash Jain.

    This is a follow-up fix for 263251@main.

    * Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
    (PullRequest.create_pull_request): Push target branch to fork if the branch doesn't exist.

    Canonical link: https://commits.webkit.org/263431@main

Canonical link: https://commits.webkit.org/259548.693@safari-7615-branch
  • Loading branch information
JonWBedard authored and webkit-early-warning-system committed Apr 26, 2023
1 parent a22a1db commit 5e67e61
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Tools/Scripts/libraries/webkitscmpy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def readme():

setup(
name='webkitscmpy',
version='6.3.0',
version='6.3.1',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _maybe_add_webkitcorepy_path():
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)

version = Version(6, 3, 0)
version = Version(6, 3, 1)

AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from .squash import Squash

from webkitbugspy import Tracker, radar
from webkitcorepy import arguments, run, Terminal
from webkitcorepy import arguments, run, Terminal, OutputCapture
from webkitscmpy import local, log, remote


Expand Down Expand Up @@ -557,16 +557,18 @@ def create_pull_request(cls, repository, args, branch_point, callback=None, unbl
if target.endswith('fork') and repository.config().get('webkitscmpy.update-fork', 'false') == 'true':
# If our remote is a GitHub repository, we can use the API and save ourselves a push
fork_remote = repository.remote(name=target)
did_update_branch = False
if isinstance(fork_remote, remote.GitHub):
log.info("Updating '{}' on '{}'".format(branch_point.branch, fork_remote.url))
fork_remote.request(
method='POST', path='merge-upstream',
json=dict(branch=branch_point.branch),
authenticated=True,
)
if run([repository.executable(), 'fetch', target, branch_point.branch], cwd=repository.root_path, capture_output=True).returncode:
with OutputCapture():
did_update_branch = fork_remote.request(
method='POST', path='merge-upstream',
json=dict(branch=branch_point.branch),
authenticated=True,
) is not None
if did_update_branch and run([repository.executable(), 'fetch', target, branch_point.branch], cwd=repository.root_path, capture_output=True).returncode:
sys.stderr.write("Failed to fetch '{}' for '{}.' Error is non fatal, continuing...\n".format(target, branch_point.branch))
elif rebasing:
if not did_update_branch and rebasing:
log.info("Syncing '{}' to remote '{}'".format(branch_point.branch, target))
if run([repository.executable(), 'push', target, '{branch}:{branch}'.format(branch=branch_point.branch)], cwd=repository.root_path, env=push_env).returncode:
sys.stderr.write("Failed to sync '{}' to '{}.' Error is non fatal, continuing...\n".format(branch_point.branch, target))
Expand Down

0 comments on commit 5e67e61

Please sign in to comment.