Title: [282409] trunk/Tools
Revision
282409
Author
jbed...@apple.com
Date
2021-09-14 14:14:59 -0700 (Tue, 14 Sep 2021)

Log 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):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (282408 => 282409)


--- trunk/Tools/ChangeLog	2021-09-14 20:21:43 UTC (rev 282408)
+++ trunk/Tools/ChangeLog	2021-09-14 21:14:59 UTC (rev 282409)
@@ -1,5 +1,21 @@
 2021-09-14  Jonathan Bedard  <jbed...@apple.com>
 
+        [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):
+
+2021-09-14  Jonathan Bedard  <jbed...@apple.com>
+
         [git-webkit] Reset author time when editing commits (Part 1)
         https://bugs.webkit.org/show_bug.cgi?id=230224
         <rdar://problem/83065417>

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (282408 => 282409)


--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2021-09-14 20:21:43 UTC (rev 282408)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2021-09-14 21:14:59 UTC (rev 282409)
@@ -29,7 +29,7 @@
 
 setup(
     name='webkitscmpy',
-    version='2.1.3',
+    version='2.2.0',
     description='Library designed to interact with git and svn repositories.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (282408 => 282409)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2021-09-14 20:21:43 UTC (rev 282408)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2021-09-14 21:14:59 UTC (rev 282409)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(2, 1, 3)
+version = Version(2, 2, 0)
 
 AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
 AutoInstall.register(Package('monotonic', Version(1, 5)))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py (282408 => 282409)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2021-09-14 20:21:43 UTC (rev 282408)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2021-09-14 21:14:59 UTC (rev 282409)
@@ -768,15 +768,33 @@
             cwd=self.root_path,
         ).returncode else self.commit()
 
-    def pull(self, rebase=None, branch=None):
-        commit = self.commit() if self.is_svn else None
+    def pull(self, rebase=None, branch=None, remote='origin'):
+        commit = self.commit() if self.is_svn or branch else None
         code = run(
             [self.executable(), 'pull'] + (
-                ['origin', branch] if branch else []
+                [remote, branch] if branch else []
             ) + (
                 [] if rebase is None else ['--rebase={}'.format('True' if rebase else 'False')]
             ), cwd=self.root_path,
         ).returncode
+
+        if not code and branch:
+            code = run(
+                [self.executable(), 'update-ref', branch, '{}/{}'.format(remote, branch)],
+                cwd=self.root_path,
+            ).returncode
+
+        if not code and branch and rebase:
+            result = run([self.executable(), 'rev-parse', 'HEAD'], cwd=self.root_path, capture_output=True, encoding='utf-8')
+            if not result.returncode and result.stdout.rstrip() != commit.hash:
+                code = run([
+                    self.executable(),
+                    'filter-branch', '-f',
+                    '--env-filter', "GIT_AUTHOR_DATE='{date}';GIT_COMMITTER_DATE='{date}'".format(
+                        date='{} -{}'.format(int(time.time()), int(time.localtime().tm_gmtoff * 100 / (60 * 60)))
+                    ), 'HEAD...{}'.format('{}/{}'.format(remote, branch)),
+                ], cwd=self.root_path, env={'FILTER_BRANCH_SQUELCH_WARNING': '1'}).returncode
+
         if not code and self.is_svn:
             return run([
                 self.executable(), 'svn', 'fetch', '--log-window-size=5000', '-r', '{}:HEAD'.format(commit.revision),

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py (282408 => 282409)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py	2021-09-14 20:21:43 UTC (rev 282408)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py	2021-09-14 21:14:59 UTC (rev 282409)
@@ -431,6 +431,10 @@
                 cwd=self.path,
                 generator=lambda *args, **kwargs: mocks.ProcessCompletion(returncode=0),
             ), mocks.Subprocess.Route(
+                self.executable, 'update-ref', re.compile(r'.+'), re.compile(r'.+'),
+                cwd=self.path,
+                generator=lambda *args, **kwargs: mocks.ProcessCompletion(returncode=0),
+            ), mocks.Subprocess.Route(
                 self.executable,
                 cwd=self.path,
                 completion=mocks.ProcessCompletion(

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py (282408 => 282409)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py	2021-09-14 20:21:43 UTC (rev 282408)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py	2021-09-14 21:14:59 UTC (rev 282409)
@@ -191,12 +191,13 @@
             self.assertDictEqual(repo.staged, {})
             self.assertEqual(repo.head.hash, 'e4390abc95a2026370b8c9813b7e55c61c5d6ebb')
 
-        self.assertEqual(captured.root.log.getvalue(), '''Creating the local development branch 'eng/pr-branch'...
+        self.assertEqual(
+            '\n'.join([line for line in captured.root.log.getvalue().splitlines() if 'Mock process' not in line]),
+            """Creating the local development branch 'eng/pr-branch'...
 Creating commit...
     Found 1 commit...
 Rebasing 'eng/pr-branch' on 'main'...
-Rebased 'eng/pr-branch' on 'main!'
-''')
+Rebased 'eng/pr-branch' on 'main!'""")
         self.assertEqual(captured.stderr.getvalue(), "'{}' doesn't have a recognized remote\n".format(self.path))
 
     def test_modified(self):
@@ -211,13 +212,14 @@
             self.assertEqual(repo.head.hash, 'd05082bf6707252aef3472692598a587ed3fb213')
 
         self.assertEqual(captured.stderr.getvalue(), "'{}' doesn't have a recognized remote\n".format(self.path))
-        self.assertEqual(captured.root.log.getvalue(), '''Creating the local development branch 'eng/pr-branch'...
+        self.assertEqual(
+            '\n'.join([line for line in captured.root.log.getvalue().splitlines() if 'Mock process' not in line]),
+            """Creating the local development branch 'eng/pr-branch'...
     Adding modified.txt...
 Creating commit...
     Found 1 commit...
 Rebasing 'eng/pr-branch' on 'main'...
-Rebased 'eng/pr-branch' on 'main!'
-''')
+Rebased 'eng/pr-branch' on 'main!'""")
 
     def test_github(self):
         with OutputCapture() as captured, mocks.remote.GitHub() as remote, \
@@ -232,7 +234,7 @@
         self.assertEqual(captured.stderr.getvalue(), '')
         log = captured.root.log.getvalue().splitlines()
         self.assertEqual(
-            log[:6] + log[9 if sys.version_info > (3, 0) else 7:], [
+            [line for line in log if 'Mock process' not in line], [
                 "Creating the local development branch 'eng/pr-branch'...",
                 'Creating commit...',
                 '    Found 1 commit...',
@@ -262,8 +264,9 @@
 
         self.assertEqual(captured.stderr.getvalue(), '')
         log = captured.root.log.getvalue().splitlines()
+        self.maxDiff = None
         self.assertEqual(
-            log[:5] + log[8 if sys.version_info > (3, 0) else 6:], [
+            [line for line in log if 'Mock process' not in line], [
                 "Amending commit...",
                 '    Found 1 commit...',
                 "Rebasing 'eng/pr-branch' on 'main'...",
@@ -288,7 +291,7 @@
         self.assertEqual(captured.stderr.getvalue(), '')
         log = captured.root.log.getvalue().splitlines()
         self.assertEqual(
-            log[:6] + log[9 if sys.version_info > (3, 0) else 7:], [
+            [line for line in log if 'Mock process' not in line], [
                 "Creating the local development branch 'eng/pr-branch'...",
                 'Creating commit...',
                 '    Found 1 commit...',
@@ -321,7 +324,7 @@
         self.assertEqual(captured.stderr.getvalue(), '')
         log = captured.root.log.getvalue().splitlines()
         self.assertEqual(
-            log[:5] + log[8 if sys.version_info > (3, 0) else 6:], [
+            [line for line in log if 'Mock process' not in line], [
                 "Amending commit...",
                 '    Found 1 commit...',
                 "Rebasing 'eng/pr-branch' on 'main'...",
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to