Skip to content
Permalink
Browse files
[git-webkit] Cleanup PRs on alternate remotes
https://bugs.webkit.org/show_bug.cgi?id=239814
<rdar://problem/92410887>

Reviewed by Aakash Jain.

* Tools/Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/clean.py:
(Clean.parser): Add --remote argument.
(Clean.cleanup): Allow caller to specify remote.
(Clean.main): Pass remote to cleanup.

Canonical link: https://commits.webkit.org/250065@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@293545 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JonWBedard committed Apr 27, 2022
1 parent 024fe2f commit 95750a8cdc2f8b33dbb67af1685fa687bb863f28
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
@@ -1,3 +1,18 @@
2022-04-27 Jonathan Bedard <jbedard@apple.com>

[git-webkit] Cleanup PRs on alternate remotes
https://bugs.webkit.org/show_bug.cgi?id=239814
<rdar://problem/92410887>

Reviewed by Aakash Jain.

* Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Scripts/libraries/webkitscmpy/webkitscmpy/program/clean.py:
(Clean.parser): Add --remote argument.
(Clean.cleanup): Allow caller to specify remote.
(Clean.main): Pass remote to cleanup.

2022-04-27 Jonathan Bedard <jbedard@apple.com>

[ews-build.webkit.org] Support alternative remotes (Follow-up fix)
@@ -29,7 +29,7 @@ def readme():

setup(
name='webkitscmpy',
version='4.11.3',
version='4.11.4',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
@@ -46,7 +46,7 @@ def _maybe_add_webkitcorepy_path():
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)

version = Version(4, 11, 3)
version = Version(4, 11, 4)

AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
@@ -41,15 +41,24 @@ def parser(cls, parser, loggers=None):
type=str, default=None,
help='String representation(s) of a commit or branch to be cleaned',
)
parser.add_argument(
'--remote', dest='remote', type=str, default=None,
help='Specify remote to search for pull request from.',
)

@classmethod
def cleanup(cls, repository, argument):
def cleanup(cls, repository, argument, remote_target=None):
if not repository.is_git:
sys.stderr('Can only cleanup branches on git repositories\n')
return 1

rmt = repository.remote()
target = 'fork' if isinstance(rmt, remote.GitHub) else 'origin'
rmt = repository.remote(name=remote_target)
if isinstance(rmt, remote.GitHub) and remote_target in (None, 'origin'):
target = 'fork'
elif isinstance(rmt, remote.GitHub):
target = '{}-fork'.format(remote_target)
else:
target = 'origin'

match = cls.PR_RE.match(argument)
if match:
@@ -103,5 +112,5 @@ def main(cls, args, repository, **kwargs):

result = 0
for argument in args.arguments:
result += cls.cleanup(repository, argument)
result += cls.cleanup(repository, argument, remote_target=args.remote)
return result

0 comments on commit 95750a8

Please sign in to comment.