Diff
Modified: trunk/Tools/ChangeLog (293614 => 293615)
--- trunk/Tools/ChangeLog 2022-04-29 15:24:12 UTC (rev 293614)
+++ trunk/Tools/ChangeLog 2022-04-29 15:35:26 UTC (rev 293615)
@@ -1,3 +1,21 @@
+2022-04-29 Jonathan Bedard <[email protected]>
+
+ [git-webkit] Redact bug title in branch name on alternate remotes
+ https://bugs.webkit.org/show_bug.cgi?id=239826
+ <rdar://problem/92418512>
+
+ Rubber-stamped by Aakash Jain.
+
+ * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/program/branch.py:
+ (Branch.main): Allow caller to redact bug title in branch name.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
+ (PullRequest.pull_request_branch_point): Redact bug title in branch name
+ for non-origin remotes.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/branch_unittest.py:
+ (TestBranch.test_redacted):
+
2022-04-27 Jonathan Bedard <[email protected]>
[ews-build.webkit.org] Link to PRs with undefined title
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (293614 => 293615)
--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-04-29 15:24:12 UTC (rev 293614)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-04-29 15:35:26 UTC (rev 293615)
@@ -29,7 +29,7 @@
setup(
name='webkitscmpy',
- version='4.12.0',
+ version='4.12.1',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (293614 => 293615)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-04-29 15:24:12 UTC (rev 293614)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-04-29 15:35:26 UTC (rev 293615)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(4, 12, 0)
+version = Version(4, 12, 1)
AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/branch.py (293614 => 293615)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/branch.py 2022-04-29 15:24:12 UTC (rev 293614)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/branch.py 2022-04-29 15:35:26 UTC (rev 293615)
@@ -92,7 +92,7 @@
return string_utils.encode(result, target_type=str)
@classmethod
- def main(cls, args, repository, why=None, **kwargs):
+ def main(cls, args, repository, why=None, redact=False, **kwargs):
if not isinstance(repository, local.Git):
sys.stderr.write("Can only 'branch' on a native Git repository\n")
return 1
@@ -100,14 +100,16 @@
if not args.issue:
args.issue = Terminal.input('{}nter name of new branch (or bug URL): '.format('{}, e'.format(why) if why else 'E'))
- if string_utils.decode(args.issue).isnumeric() and Tracker.instance():
+ if string_utils.decode(args.issue).isnumeric() and Tracker.instance() and not redact:
issue = Tracker.instance().issue(int(args.issue))
if issue and issue.title:
args.issue = cls.to_branch_name(issue.title)
else:
issue = Tracker.from_string(args.issue)
- if issue and issue.title:
+ if issue and issue.title and not redact:
args.issue = cls.to_branch_name(issue.title)
+ elif issue:
+ args.issue = str(issue.id)
args.issue = cls.normalize_branch_name(args.issue)
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py (293614 => 293615)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py 2022-04-29 15:24:12 UTC (rev 293614)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py 2022-04-29 15:35:26 UTC (rev 293615)
@@ -145,8 +145,15 @@
@classmethod
def pull_request_branch_point(cls, repository, args, **kwargs):
+ # FIXME: We can do better by infering the remote from the branch point, if it's not specified
+ source_remote = args.remote or 'origin'
+
if repository.branch in repository.DEFAULT_BRANCHES or repository.PROD_BRANCHES.match(repository.branch):
- if Branch.main(args, repository, why="'{}' is not a pull request branch".format(repository.branch), **kwargs):
+ if Branch.main(
+ args, repository,
+ why="'{}' is not a pull request branch".format(repository.branch),
+ redact=source_remote != 'origin', **kwargs
+ ):
sys.stderr.write("Abandoning pushing pull-request because '{}' could not be created\n".format(args.issue))
return None
elif args.issue and repository.branch != args.issue:
@@ -153,8 +160,6 @@
sys.stderr.write("Creating a pull-request for '{}' but we're on '{}'\n".format(args.issue, repository.branch))
return None
- # FIXME: We can do better by infering the remote from the branch point, if it's not specified
- source_remote = args.remote or 'origin'
if not repository.config().get('remote.{}.url'.format(source_remote)):
sys.stderr.write("'{}' is not a remote in this repository\n".format(source_remote))
return None
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/branch_unittest.py (293614 => 293615)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/branch_unittest.py 2022-04-29 15:24:12 UTC (rev 293614)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/branch_unittest.py 2022-04-29 15:35:26 UTC (rev 293615)
@@ -27,7 +27,7 @@
from webkitbugspy import bugzilla, mocks as bmocks, radar
from webkitcorepy import OutputCapture, testing
from webkitcorepy.mocks import Time as MockTime, Terminal as MockTerminal, Environment
-from webkitscmpy import local, program, mocks
+from webkitscmpy import local, program, mocks, log
class TestBranch(testing.PathTestCase):
@@ -95,6 +95,24 @@
self.assertEqual(captured.root.log.getvalue(), "Creating the local development branch 'eng/Example-feature-1'...\n")
self.assertEqual(captured.stdout.getvalue(), "Enter name of new branch (or bug URL): \nCreated the local development branch 'eng/Example-feature-1'\n")
+ def test_redacted(self):
+ class MockOptions(object):
+ def __init__(self):
+ self.issue = None
+
+ with MockTerminal.input('<rdar://2>'), OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path), \
+ bmocks.Radar(issues=bmocks.ISSUES), patch('webkitbugspy.Tracker._trackers', [radar.Tracker()]), mocks.local.Svn(), MockTime:
+
+ log.setLevel(logging.INFO)
+ self.assertEqual(0, program.Branch.main(
+ MockOptions(), local.Git(self.path),
+ redact=True,
+ ))
+ self.assertEqual(local.Git(self.path).branch, 'eng/2')
+ self.assertEqual(captured.root.log.getvalue(), "Creating the local development branch 'eng/2'...\n")
+ self.assertEqual(captured.stdout.getvalue(), "Enter name of new branch (or bug URL): \nCreated the local development branch 'eng/2'\n")
+
+
def test_invalid_branch(self):
with OutputCapture() as captured, mocks.local.Git(self.path), mocks.local.Svn(), MockTime:
self.assertEqual(1, program.main(