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

Changeset 282409 in webkit


Ignore:
Timestamp:
Sep 14, 2021, 2:14:59 PM (5 years ago)
Author:
Jonathan Bedard
Message:

[git-webkit] Reset author time when editing commits (Part 2)
​https://bugs.webkit.org/show_bug.cgi?id=230224
<rdar://problem/83065417>

Reviewed by Stephanie Lewis.

  • Scripts/libraries/webkitscmpy/setup.py: Bump version.
  • Scripts/libraries/webkitscmpy/webkitscmpy/init.py: Ditto.
  • Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:

(Git.pull): Force-update ref of pulled branch, reset author time of all rebased commits.

  • Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py: Add update-ref mock.
  • Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:

(TestDoPullRequest):

Location:
trunk/Tools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r282404 r282409  
     12021-09-14  Jonathan Bedard  <jbedard@apple.com>
     2
     3        [git-webkit] Reset author time when editing commits (Part 2)
     4        https://bugs.webkit.org/show_bug.cgi?id=230224
     5        <rdar://problem/83065417>
     6
     7        Reviewed by Stephanie Lewis.
     8
     9        * Scripts/libraries/webkitscmpy/setup.py: Bump version.
     10        * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
     11        * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
     12        (Git.pull): Force-update ref of pulled branch, reset author time of all rebased commits.
     13        * Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py: Add update-ref mock.
     14        * Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:
     15        (TestDoPullRequest):
     16
    1172021-09-14  Jonathan Bedard  <jbedard@apple.com>
    218
  • trunk/Tools/Scripts/libraries/webkitscmpy/setup.py

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

    r282113 r282409  
    4747    )
    4848
    49 version = Version(2, 1, 3)
     49version = Version(2, 2, 0)
    5050
    5151AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py

    r282113 r282409  
    769769        ).returncode else self.commit()
    770770
    771     def pull(self, rebase=None, branch=None):
    772         commit = self.commit() if self.is_svn else None
     771    def pull(self, rebase=None, branch=None, remote='origin'):
     772        commit = self.commit() if self.is_svn or branch else None
    773773        code = run(
    774774            [self.executable(), 'pull'] + (
    775                 ['origin', branch] if branch else []
     775                [remote, branch] if branch else []
    776776            ) + (
    777777                [] if rebase is None else ['--rebase={}'.format('True' if rebase else 'False')]
    778778            ), cwd=self.root_path,
    779779        ).returncode
     780
     781        if not code and branch:
     782            code = run(
     783                [self.executable(), 'update-ref', branch, '{}/{}'.format(remote, branch)],
     784                cwd=self.root_path,
     785            ).returncode
     786
     787        if not code and branch and rebase:
     788            result = run([self.executable(), 'rev-parse', 'HEAD'], cwd=self.root_path, capture_output=True, encoding='utf-8')
     789            if not result.returncode and result.stdout.rstrip() != commit.hash:
     790                code = run([
     791                    self.executable(),
     792                    'filter-branch', '-f',
     793                    '--env-filter', "GIT_AUTHOR_DATE='{date}';GIT_COMMITTER_DATE='{date}'".format(
     794                        date='{} -{}'.format(int(time.time()), int(time.localtime().tm_gmtoff * 100 / (60 * 60)))
     795                    ), 'HEAD...{}'.format('{}/{}'.format(remote, branch)),
     796                ], cwd=self.root_path, env={'FILTER_BRANCH_SQUELCH_WARNING': '1'}).returncode
     797
    780798        if not code and self.is_svn:
    781799            return run([
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py

    r282404 r282409  
    432432                generator=lambda *args, **kwargs: mocks.ProcessCompletion(returncode=0),
    433433            ), mocks.Subprocess.Route(
     434                self.executable, 'update-ref', re.compile(r'.+'), re.compile(r'.+'),
     435                cwd=self.path,
     436                generator=lambda *args, **kwargs: mocks.ProcessCompletion(returncode=0),
     437            ), mocks.Subprocess.Route(
    434438                self.executable,
    435439                cwd=self.path,
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py

    r281821 r282409  
    192192            self.assertEqual(repo.head.hash, 'e4390abc95a2026370b8c9813b7e55c61c5d6ebb')
    193193
    194         self.assertEqual(captured.root.log.getvalue(), '''Creating the local development branch 'eng/pr-branch'...
     194        self.assertEqual(
     195            '\n'.join([line for line in captured.root.log.getvalue().splitlines() if 'Mock process' not in line]),
     196            """Creating the local development branch 'eng/pr-branch'...
    195197Creating commit...
    196198    Found 1 commit...
    197199Rebasing 'eng/pr-branch' on 'main'...
    198 Rebased 'eng/pr-branch' on 'main!'
    199 ''')
     200Rebased 'eng/pr-branch' on 'main!'""")
    200201        self.assertEqual(captured.stderr.getvalue(), "'{}' doesn't have a recognized remote\n".format(self.path))
    201202
    … …  
    212213
    213214        self.assertEqual(captured.stderr.getvalue(), "'{}' doesn't have a recognized remote\n".format(self.path))
    214         self.assertEqual(captured.root.log.getvalue(), '''Creating the local development branch 'eng/pr-branch'...
     215        self.assertEqual(
     216            '\n'.join([line for line in captured.root.log.getvalue().splitlines() if 'Mock process' not in line]),
     217            """Creating the local development branch 'eng/pr-branch'...
    215218    Adding modified.txt...
    216219Creating commit...
    217220    Found 1 commit...
    218221Rebasing 'eng/pr-branch' on 'main'...
    219 Rebased 'eng/pr-branch' on 'main!'
    220 ''')
     222Rebased 'eng/pr-branch' on 'main!'""")
    221223
    222224    def test_github(self):
    … …  
    233235        log = captured.root.log.getvalue().splitlines()
    234236        self.assertEqual(
    235             log[:6] + log[9 if sys.version_info > (3, 0) else 7:], [
     237            [line for line in log if 'Mock process' not in line], [
    236238                "Creating the local development branch 'eng/pr-branch'...",
    237239                'Creating commit...',
    … …  
    263265        self.assertEqual(captured.stderr.getvalue(), '')
    264266        log = captured.root.log.getvalue().splitlines()
    265         self.assertEqual(
    266             log[:5] + log[8 if sys.version_info > (3, 0) else 6:], [
     267        self.maxDiff = None
     268        self.assertEqual(
     269            [line for line in log if 'Mock process' not in line], [
    267270                "Amending commit...",
    268271                '    Found 1 commit...',
    … …  
    289292        log = captured.root.log.getvalue().splitlines()
    290293        self.assertEqual(
    291             log[:6] + log[9 if sys.version_info > (3, 0) else 7:], [
     294            [line for line in log if 'Mock process' not in line], [
    292295                "Creating the local development branch 'eng/pr-branch'...",
    293296                'Creating commit...',
    … …  
    322325        log = captured.root.log.getvalue().splitlines()
    323326        self.assertEqual(
    324             log[:5] + log[8 if sys.version_info > (3, 0) else 6:], [
     327            [line for line in log if 'Mock process' not in line], [
    325328                "Amending commit...",
    326329                '    Found 1 commit...',
Note: See TracChangeset for help on using the changeset viewer.