⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287853 in webkit


Ignore:
Timestamp:
Jan 10, 2022, 1:09:28 PM (5 years ago)
Author:
Jonathan Bedard
Message:

[git-webkit] Retain old commits in pull-request
https://bugs.webkit.org/show_bug.cgi?id=234453
<rdar://problem/86654956>

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/land.py:

(Land.main): Find all numbered branches for landing pull-request.

  • Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:

(PullRequest.parser): Add history option.
(PullRequest.main): Add a numbered branch which persists through the life of the pull-request.

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

Location:
trunk/Tools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r287849 r287853  
     12021-12-17  Jonathan Bedard  <jbedard@apple.com>
     2
     3        [git-webkit] Retain old commits in pull-request
     4        https://bugs.webkit.org/show_bug.cgi?id=234453
     5        <rdar://problem/86654956>
     6
     7        Reviewed by Dewei Zhu.
     8
     9        * Scripts/libraries/webkitscmpy/setup.py: Bump version.
     10        * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
     11        * Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py:
     12        (Land.main): Find all numbered branches for landing pull-request.
     13        * Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
     14        (PullRequest.parser): Add history option.
     15        (PullRequest.main): Add a numbered branch which persists through the life of the pull-request.
     16
    1172022-01-10  Wenson Hsieh  <wenson_hsieh@apple.com>
    218
  • trunk/Tools/Scripts/libraries/webkitscmpy/setup.py

    r287587 r287853  
    3030setup(
    3131    name='webkitscmpy',
    32     version='3.0.7',
     32    version='3.1.0',
    3333    description='Library designed to interact with git and svn repositories.',
    3434    long_description=readme(),
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py

    r287587 r287853  
    4747    )
    4848
    49 version = Version(3, 0, 7)
     49version = Version(3, 1, 0)
    5050
    5151AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/land.py

    r286295 r287853  
    233233
    234234        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)
     235            regex = re.compile(r'^{}-(?P<count>\d+)$'.format(repository.branch))
     236            for to_delete in repository.branches_for(remote='fork'):
     237                if to_delete == source_branch or regex.match(to_delete):
     238                    run([repository.executable(), 'branch', '-D', to_delete], cwd=repository.root_path)
     239                    run([repository.executable(), 'push', remote_target, '--delete', to_delete], cwd=repository.root_path)
    237240        return 0
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py

    r287587 r287853  
    2222
    2323import os
     24import re
    2425import sys
    2526
     
    5455            '--defaults', '--no-defaults', action=arguments.NoAction, default=None,
    5556            help='Do not prompt the user for defaults, always use (or do not use) them',
     57        )
     58        parser.add_argument(
     59            '--with-history', '--no-history',
     60            dest='history', default=None,
     61            help='Create numbered branches to track the history of a change',
     62            action=arguments.NoAction,
    5663        )
    5764
     
    131138            sys.stderr.write("Failed to push '{}' to '{}'\n".format(repository.branch, target))
    132139            return 1
     140
     141        if args.history or (target != 'origin' and args.history is None):
     142            regex = re.compile(r'^{}-(?P<count>\d+)$'.format(repository.branch))
     143            count = max([
     144                int(regex.match(branch).group('count')) if regex.match(branch) else 0 for branch in
     145                repository.branches_for(remote=target)
     146            ] + [0]) + 1
     147
     148            history_branch = '{}-{}'.format(repository.branch, count)
     149            log.info("Creating '{}' as a reference branch".format(history_branch))
     150            if run([
     151                repository.executable(), 'branch', history_branch, repository.branch,
     152            ], cwd=repository.root_path).returncode or run([
     153                repository.executable(), 'push', '-f', target, history_branch,
     154            ], cwd=repository.root_path).returncode:
     155                sys.stderr.write("Failed to create and push '{}' to '{}'\n".format(history_branch, target))
    133156
    134157        if not rmt.pull_requests:
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py

    r286295 r287853  
    323323            repo.staged['added.txt'] = 'added'
    324324            self.assertEqual(0, program.main(
    325                 args=('pull-request', '-i', 'pr-branch', '-v'),
     325                args=('pull-request', '-i', 'pr-branch', '-v', '--no-history'),
    326326                path=self.path,
    327327            ))
     
    359359                repo.staged['added.txt'] = 'diff'
    360360                self.assertEqual(0, program.main(
    361                     args=('pull-request', '-v'),
     361                    args=('pull-request', '-v', '--no-history'),
    362362                    path=self.path,
    363363                ))
     
    393393                repo.staged['added.txt'] = 'diff'
    394394                self.assertEqual(0, program.main(
    395                     args=('pull-request', '-v'),
     395                    args=('pull-request', '-v', '--no-history'),
    396396                    path=self.path,
    397397                ))
Note: See TracChangeset for help on using the changeset viewer.