Title: [295470] trunk/Tools/Scripts/libraries/webkitscmpy
Revision
295470
Author
jbed...@apple.com
Date
2022-06-10 18:33:15 -0700 (Fri, 10 Jun 2022)

Log Message

[git-webkit] Make the default rebase behavior for `git-webkit pr` configurable
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

Modified Paths

Diff

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (295469 => 295470)


--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-06-11 00:35:48 UTC (rev 295469)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2022-06-11 01:33:15 UTC (rev 295470)
@@ -29,7 +29,7 @@
 
 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=[

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (295469 => 295470)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-06-11 00:35:48 UTC (rev 295469)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2022-06-11 01:33:15 UTC (rev 295470)
@@ -46,7 +46,7 @@
         "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)))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py (295469 => 295470)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py	2022-06-11 00:35:48 UTC (rev 295469)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py	2022-06-11 01:33:15 UTC (rev 295470)
@@ -267,7 +267,11 @@
             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):

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py (295469 => 295470)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py	2022-06-11 00:35:48 UTC (rev 295469)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py	2022-06-11 01:33:15 UTC (rev 295470)
@@ -250,6 +250,25 @@
             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'

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/setup_unittest.py (295469 => 295470)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/setup_unittest.py	2022-06-11 00:35:48 UTC (rev 295469)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/setup_unittest.py	2022-06-11 01:33:15 UTC (rev 295470)
@@ -119,7 +119,7 @@
 
     def test_github_checkout(self):
         with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub() as remote, \
-            MockTerminal.input('n', 'n', 'commit...@webkit.org', 'n', 'Committer', 's', 'overwrite', 'disabled', '1', 'y'), \
+            MockTerminal.input('n', 'n', 'commit...@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 @@
 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 @@
 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...
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to