Skip to content
Permalink
Browse files
[git-webkit] Make the default rebase behavior for git-webkit pr con…
…figurable

https://bugs.webkit.org/show_bug.cgi?id=239385
<rdar://problem/91811534>

Reviewed by Dewei Zhu.

* Tools/Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
(PullRequest.main): Check the webkitscmpy.auto-rebase-branch option to determine
if we should automatically rebase the branch.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py:
(Setup.git): Prompt user to set the automatic rebase behavior.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/setup_unittest.py:

Canonical link: https://commits.webkit.org/251475@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295470 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JonWBedard committed Jun 11, 2022
1 parent e82df92 commit b4c270a0742517728c686c774f30d33f0ac4c547
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
@@ -29,7 +29,7 @@ def readme():

setup(
name='webkitscmpy',
version='5.0.0',
version='5.0.1',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
@@ -46,7 +46,7 @@ def _maybe_add_webkitcorepy_path():
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)

version = Version(5, 0, 0)
version = Version(5, 0, 1)

AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
@@ -267,7 +267,11 @@ def create_pull_request(cls, repository, args, branch_point):
sys.stderr.write("'{}' is not a remote in this repository\n".format(source_remote))
return 1

rebasing = args.rebase or (args.rebase is None and repository.config().get('pull.rebase'))
rebasing = args.rebase if args.rebase is not None else repository.config().get(
'webkitscmpy.auto-rebase-branch',
repository.config().get('pull.rebase', 'true'),
) == 'true'

if rebasing:
log.info("Rebasing '{}' on '{}'...".format(repository.branch, branch_point.branch))
if repository.pull(rebase=True, branch=branch_point.branch):
@@ -250,6 +250,25 @@ def git(cls, args, repository, additional_setup=None, hooks=None, **kwargs):
sys.stderr.write('Failed to use {} as the merge strategy for this repository\n'.format('merge commits' if args.merge else 'rebase'))
result += 1

need_prompt_auto_update = args.all or not local_config.get('webkitscmpy.auto-rebase-branch')
if not args.merge and not args.defaults and need_prompt_auto_update:
log.info('Setting auto update on PR creation...')
response = Terminal.choose(
'Would you like to automatically rebase your branch when creating or\nupdating a pull request?',
default='Yes', options=('Yes', 'No', 'Later'),
)
if response in ['Yes', 'No']:
if run(
[local.Git.executable(), 'config', 'webkitscmpy.auto-rebase-branch', 'true' if response == 'Yes' else 'false'],
capture_output=True, cwd=repository.root_path,
).returncode:
sys.stderr.write('Failed to {} auto update\n'.format('enable' if response == 'Yes' else 'disable'))
result += 1
else:
log.info('{} auto update on PR creation'.format('Enabled' if response == 'Yes' else 'Disabled'))
else:
log.info('Skipped explicit auto update configuration')

if args.all or not local_config.get('webkitscmpy.history'):
if repository.config(location='project')['webkitscmpy.history'] == 'never':
pr_history = 'never'
@@ -119,7 +119,7 @@ def test_git(self):

def test_github_checkout(self):
with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub() as remote, \
MockTerminal.input('n', 'n', 'committer@webkit.org', 'n', 'Committer', 's', 'overwrite', 'disabled', '1', 'y'), \
MockTerminal.input('n', 'n', 'committer@webkit.org', 'n', 'Committer', 's', 'overwrite', 'y', 'disabled', '1', 'y'), \
mocks.local.Git(self.path, remote='https://{}.git'.format(remote.remote)) as repo, \
wkmocks.Environment(EMAIL_ADDRESS='', SVN_LOG_EDITOR=''):

@@ -150,6 +150,8 @@ def test_github_checkout(self):
Set 'Tim Apple' as the git user name for this repository ([Yes]/No):
Enter git user name for this repository:
Auto-color status, diff, and branch for this repository? ([Yes]/Skip):
Would you like to automatically rebase your branch when creating or
updating a pull request? ([Yes]/No/Later):
Would you like to create new branches to retain history when you overwrite
a pull request branch? ([when-user-owned]/disabled/always/never):
Pick a commit message editor for this repository:
@@ -173,6 +175,8 @@ def test_github_checkout(self):
Setting better Objective-C diffing behavior for this repository...
Set better Objective-C diffing behavior for this repository!
Using a rebase merge strategy for this repository
Setting auto update on PR creation...
Enabled auto update on PR creation
Setting git editor for {repository}...
Using the default git editor for this repository
Saving GitHub credentials in system credential store...

0 comments on commit b4c270a

Please sign in to comment.