Title: [291252] trunk/Tools
Revision
291252
Author
[email protected]
Date
2022-03-14 14:59:31 -0700 (Mon, 14 Mar 2022)

Log Message

[EWS] Clean up PR branches and remotes
https://bugs.webkit.org/show_bug.cgi?id=237714
<rdar://problem/88771970>

Reviewed by Aakash Jain.

* Tools/CISupport/ews-build/steps.py:
(ShellMixin.shell_command): Use `sh` on Windows.
(CleanGitRepo.run): Delete all non-origin remote and all unused branches.
* Tools/CISupport/ews-build/steps_unittest.py:

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

Modified Paths

Diff

Modified: trunk/Tools/CISupport/ews-build/steps.py (291251 => 291252)


--- trunk/Tools/CISupport/ews-build/steps.py	2022-03-14 21:14:21 UTC (rev 291251)
+++ trunk/Tools/CISupport/ews-build/steps.py	2022-03-14 21:59:31 UTC (rev 291252)
@@ -263,7 +263,7 @@
 
     def shell_command(self, command):
         if self.has_windows_shell():
-            return ['cmd', '/c', command]
+            return ['sh', '-c', command]
         return ['/bin/sh', '-c', command]
 
     def shell_exit_0(self):
@@ -4146,6 +4146,8 @@
             ['git', 'checkout', '{}/{}'.format(self.git_remote, branch), '-f'],  # Checkout branch from specific remote
             ['git', 'branch', '-D', '{}'.format(branch)],  # Delete any local cache of the specified branch
             ['git', 'checkout', '{}/{}'.format(self.git_remote, branch), '-b', '{}'.format(branch)],  # Checkout local instance of branch from remote
+            self.shell_command('git branch | grep -v {} | grep -v {} | xargs git branch -D || {}'.format(self.default_branch, branch, self.shell_exit_0())),
+            self.shell_command('git remote | grep -v {} | xargs -L 1 git remote rm || {}'.format(self.git_remote, self.shell_exit_0())),
         ]:
             self.commands.append(util.ShellArg(command=command, logname='stdio'))
         return super(CleanGitRepo, self).run()

Modified: trunk/Tools/CISupport/ews-build/steps_unittest.py (291251 => 291252)


--- trunk/Tools/CISupport/ews-build/steps_unittest.py	2022-03-14 21:14:21 UTC (rev 291251)
+++ trunk/Tools/CISupport/ews-build/steps_unittest.py	2022-03-14 21:59:31 UTC (rev 291252)
@@ -3291,7 +3291,7 @@
                 timeout=600,
                 logEnviron=False,
                 env=self.ENV,
-                command=['cmd', '/c', 'git remote add Contributor https://github.com/Contributor/WebKit.git || exit 0'],
+                command=['sh', '-c', 'git remote add Contributor https://github.com/Contributor/WebKit.git || exit 0'],
             ) + 0, ExpectShell(
                 workdir='wkdir',
                 timeout=600,
@@ -4773,6 +4773,10 @@
             + ExpectShell.log('stdio', stdout='Deleted branch main (was 57015967fef9).'),
             ExpectShell(command=['git', 'checkout', 'origin/main', '-b', 'main'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout="Switched to a new branch 'main'"),
+            ExpectShell(command=['/bin/sh', '-c', 'git branch | grep -v main | grep -v main | xargs git branch -D || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['/bin/sh', '-c', 'git remote | grep -v origin | xargs -L 1 git remote rm || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
         )
         self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
         return self.runStep()
@@ -4783,7 +4787,7 @@
         self.setProperty('platform', 'wincairo')
 
         self.expectRemoteCommands(
-            ExpectShell(command=['cmd', '/c', 'git rebase --abort || exit 0'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            ExpectShell(command=['sh', '-c', 'git rebase --abort || exit 0'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout=''),
             ExpectShell(command=['git', 'clean', '-f', '-d'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout=''),
@@ -4795,6 +4799,10 @@
             + ExpectShell.log('stdio', stdout='Deleted branch main (was 57015967fef9).'),
             ExpectShell(command=['git', 'checkout', 'origin/main', '-b', 'main'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout="Switched to a new branch 'main'"),
+            ExpectShell(command=['sh', '-c', 'git branch | grep -v main | grep -v main | xargs git branch -D || exit 0'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['sh', '-c', 'git remote | grep -v origin | xargs -L 1 git remote rm || exit 0'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
         )
         self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
         return self.runStep()
@@ -4816,6 +4824,10 @@
             + ExpectShell.log('stdio', stdout='Deleted branch master (was 57015967fef9).'),
             ExpectShell(command=['git', 'checkout', 'origin/master', '-b', 'master'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout="Switched to a new branch 'master'"),
+            ExpectShell(command=['/bin/sh', '-c', 'git branch | grep -v master | grep -v master | xargs git branch -D || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['/bin/sh', '-c', 'git remote | grep -v origin | xargs -L 1 git remote rm || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
         )
         self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
         return self.runStep()
@@ -4837,6 +4849,10 @@
             + ExpectShell.log('stdio', stdout='Deleted branch main (was 57015967fef9).'),
             ExpectShell(command=['git', 'checkout', 'origin/main', '-b', 'main'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout="Switched to a new branch 'main'"),
+            ExpectShell(command=['/bin/sh', '-c', 'git branch | grep -v main | grep -v main | xargs git branch -D || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['/bin/sh', '-c', 'git remote | grep -v origin | xargs -L 1 git remote rm || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
         )
         self.expectOutcome(result=FAILURE, state_string='Encountered some issues during cleanup')
         return self.runStep()
@@ -4859,6 +4875,10 @@
             + ExpectShell.log('stdio', stdout='Deleted branch safari-612-branch (was 57015967fef9).'),
             ExpectShell(command=['git', 'checkout', 'origin/safari-612-branch', '-b', 'safari-612-branch'], workdir='wkdir', timeout=300, logEnviron=False) + 0
             + ExpectShell.log('stdio', stdout="Switched to a new branch 'safari-612-branch'"),
+            ExpectShell(command=['/bin/sh', '-c', 'git branch | grep -v main | grep -v safari-612-branch | xargs git branch -D || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
+            ExpectShell(command=['/bin/sh', '-c', 'git remote | grep -v origin | xargs -L 1 git remote rm || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+            + ExpectShell.log('stdio', stdout=''),
         )
         self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
         return self.runStep()

Modified: trunk/Tools/ChangeLog (291251 => 291252)


--- trunk/Tools/ChangeLog	2022-03-14 21:14:21 UTC (rev 291251)
+++ trunk/Tools/ChangeLog	2022-03-14 21:59:31 UTC (rev 291252)
@@ -1,3 +1,16 @@
+2022-03-10  Jonathan Bedard  <[email protected]>
+
+        [EWS] Clean up PR branches and remotes
+        https://bugs.webkit.org/show_bug.cgi?id=237714
+        <rdar://problem/88771970>
+
+        Reviewed by Aakash Jain.
+
+        * CISupport/ews-build/steps.py:
+        (ShellMixin.shell_command): Use `sh` on Windows.
+        (CleanGitRepo.run): Delete all non-origin remote and all unused branches.
+        * CISupport/ews-build/steps_unittest.py:
+
 2022-03-14  Jonathan Bedard  <[email protected]>
 
         [git-webkit] Handle comparing User and Contributor to None
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to