Diff
Modified: trunk/Tools/ChangeLog (293874 => 293875)
--- trunk/Tools/ChangeLog 2022-05-06 00:24:01 UTC (rev 293874)
+++ trunk/Tools/ChangeLog 2022-05-06 00:49:04 UTC (rev 293875)
@@ -1,3 +1,24 @@
+2022-05-05 Jonathan Bedard <jbed...@apple.com>
+
+ [git-webkit] Automatically file bug
+ https://bugs.webkit.org/show_bug.cgi?id=240139
+ <rdar://problem/92818331>
+
+ Reviewed by Dewei Zhu.
+
+ * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/program/branch.py:
+ (Branch.main): If a project has defined bug trackers and the user provides a bug title instead of a bug
+ url or branch name (determined by spaces in the provided string), walk the user through bug creation.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/branch_unittest.py:
+ (TestBranch): Add mock issues, rebase prompts.
+ (TestBranch.test_create_bug): Added.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/revert_unittest.py:
+ (TestRevert.test_github): Add mock issues, rebase prompts.
+ (TestRevert.test_modified): Ditto.
+
2022-05-05 Sihui Liu <sihui_...@apple.com>
SuspendableWorkQueue::suspend should invoke callback immediately when queue is suspended
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (293874 => 293875)
--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-05-06 00:24:01 UTC (rev 293874)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py 2022-05-06 00:49:04 UTC (rev 293875)
@@ -29,7 +29,7 @@
setup(
name='webkitscmpy',
- version='4.12.4',
+ version='4.13.0',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (293874 => 293875)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-05-06 00:24:01 UTC (rev 293874)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py 2022-05-06 00:49:04 UTC (rev 293875)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(4, 12, 4)
+version = Version(4, 13, 0)
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 (293874 => 293875)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/branch.py 2022-05-06 00:24:01 UTC (rev 293874)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/branch.py 2022-05-06 00:49:04 UTC (rev 293875)
@@ -98,7 +98,11 @@
return 1
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 Tracker.instance():
+ prompt = '{}nter issue URL or title of new issue: '.format('{}, e'.format(why) if why else 'E')
+ else:
+ prompt = '{}nter name of new branch (or issue URL): '.format('{}, e'.format(why) if why else 'E')
+ args.issue = Terminal.input(prompt)
if string_utils.decode(args.issue).isnumeric() and Tracker.instance() and not redact:
issue = Tracker.instance().issue(int(args.issue))
@@ -111,6 +115,20 @@
elif issue:
args.issue = str(issue.id)
+ if not issue and Tracker.instance():
+ if ' ' in args.issue:
+ issue = Tracker.instance().create(
+ title=args.issue,
+ description=Terminal.input('Issue description: '),
+ )
+ print("Created '{}'".format(issue))
+ if issue and issue.title and not redact:
+ args.issue = cls.to_branch_name(issue.title)
+ elif issue:
+ args.issue = str(issue.id)
+ else:
+ log.warning("'{}' has no spaces, assuming user intends it to be a branch name".format(args.issue))
+
if issue:
args._title = issue.title
args._bug_urls = [issue.link]
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/branch_unittest.py (293874 => 293875)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/branch_unittest.py 2022-05-06 00:24:01 UTC (rev 293874)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/branch_unittest.py 2022-05-06 00:49:04 UTC (rev 293875)
@@ -25,7 +25,7 @@
from mock import patch
from webkitbugspy import bugzilla, mocks as bmocks, radar
-from webkitcorepy import OutputCapture, testing
+from webkitcorepy import OutputCapture, testing, mocks as wkmocks
from webkitcorepy.mocks import Time as MockTime, Terminal as MockTerminal, Environment
from webkitscmpy import local, program, mocks, log
@@ -66,11 +66,14 @@
self.assertEqual(captured.stdout.getvalue(), "Created the local development branch 'eng/1234'\n")
def test_prompt_git(self):
- with MockTerminal.input('eng/example'), OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path), mocks.local.Svn(), MockTime:
+ with MockTerminal.input('eng/example'), OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path), \
+ mocks.local.Svn(), MockTime, patch('webkitbugspy.Tracker._trackers', []):
+
self.assertEqual(0, program.main(args=('branch', '-v'), path=self.path))
self.assertEqual(local.Git(self.path).branch, 'eng/example')
+
self.assertEqual(captured.root.log.getvalue(), "Creating the local development branch 'eng/example'...\n")
- self.assertEqual(captured.stdout.getvalue(), "Enter name of new branch (or bug URL): \nCreated the local development branch 'eng/example'\n")
+ self.assertEqual(captured.stdout.getvalue(), "Enter name of new branch (or issue URL): \nCreated the local development branch 'eng/example'\n")
def test_prompt_number(self):
with MockTerminal.input('2'), OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path), bmocks.Bugzilla(
@@ -84,7 +87,7 @@
self.assertEqual(0, program.main(args=('branch', '-v'), path=self.path))
self.assertEqual(local.Git(self.path).branch, 'eng/Example-feature-1')
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")
+ self.assertEqual(captured.stdout.getvalue(), "Enter issue URL or title of new issue: \nCreated the local development branch 'eng/Example-feature-1'\n")
def test_prompt_url(self):
with MockTerminal.input('<rdar://2>'), OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path), \
@@ -93,7 +96,7 @@
self.assertEqual(0, program.main(args=('branch', '-v'), path=self.path))
self.assertEqual(local.Git(self.path).branch, 'eng/Example-feature-1')
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")
+ self.assertEqual(captured.stdout.getvalue(), "Enter issue URL or title of new issue: \nCreated the local development branch 'eng/Example-feature-1'\n")
def test_redacted(self):
class MockOptions(object):
@@ -110,11 +113,11 @@
))
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")
+ self.assertEqual(captured.stdout.getvalue(), "Enter issue URL or title of new issue: \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:
+ with OutputCapture() as captured, mocks.local.Git(self.path), mocks.local.Svn(), MockTime, patch('webkitbugspy.Tracker._trackers', []):
self.assertEqual(1, program.main(
args=('branch', '-i', 'reject_underscores'),
path=self.path,
@@ -121,6 +124,59 @@
))
self.assertEqual(captured.stderr.getvalue(), "'eng/reject_underscores' is an invalid branch name, cannot create it\n")
+ def test_create_bug(self):
+ self.maxDiff = None
+ with MockTerminal.input('2'), OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path), bmocks.Bugzilla(
+ self.BUGZILLA.split('://')[-1],
+ issues=bmocks.ISSUES,
+ projects=bmocks.PROJECTS,
+ environment=Environment(
+ BUGS_EXAMPLE_COM_USERNAME='tcontribu...@example.com',
+ BUGS_EXAMPLE_COM_PASSWORD='password',
+ ),
+ ), patch('webkitbugspy.Tracker._trackers', [bugzilla.Tracker(self.BUGZILLA)]), mocks.local.Svn(), MockTime, wkmocks.Terminal.input(
+ '[Area] New Issue', 'Issue created via command line prompts.',
+ '2', '1', '2',
+ ):
+ self.assertEqual(0, program.main(
+ args=('branch', ),
+ path=self.path,
+ ))
+ self.assertEqual(local.Git(self.path).branch, 'eng/Area-New-Issue')
+
+ issue = bugzilla.Tracker(self.BUGZILLA).issue(4)
+ self.assertEqual(issue.title, '[Area] New Issue')
+ self.assertEqual(issue.description, 'Issue created via command line prompts.')
+ self.assertEqual(issue.project, 'WebKit')
+ self.assertEqual(issue.component, 'SVG')
+ self.assertEqual(issue.version, 'Safari 15')
+
+ self.assertEqual(
+ captured.stdout.getvalue(),
+ '''Enter issue URL or title of new issue:
+Issue description:
+What project should the bug be associated with?:
+ 1) CFNetwork
+ 2) WebKit
+:
+What component in 'WebKit' should the bug be associated with?:
+ 1) SVG
+ 2) Scrolling
+ 3) Tables
+ 4) Text
+:
+What version of 'WebKit' should the bug be associated with?:
+ 1) Other
+ 2) Safari 15
+ 3) Safari Technology Preview
+ 4) WebKit Local Build
+:
+Created 'https://bugs.example.com/show_bug.cgi?id=4 [Area] New Issue'
+Created the local development branch 'eng/Area-New-Issue'
+''',
+ )
+ self.assertEqual(captured.stderr.getvalue(), '')
+
def test_to_branch_name(self):
self.assertEqual(program.Branch.to_branch_name('something with spaces'), 'something-with-spaces')
self.assertEqual(program.Branch.to_branch_name('[EWS] bug description'), 'EWS-bug-description')
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py (293874 => 293875)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py 2022-05-06 00:24:01 UTC (rev 293874)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py 2022-05-06 00:49:04 UTC (rev 293875)
@@ -259,7 +259,7 @@
os.mkdir(os.path.join(self.path, '.svn'))
def test_svn(self):
- with OutputCapture(level=logging.INFO) as captured, mocks.local.Git(), mocks.local.Svn(self.path):
+ with OutputCapture(level=logging.INFO) as captured, mocks.local.Git(), mocks.local.Svn(self.path), patch('webkitbugspy.Tracker._trackers', []):
self.assertEqual(1, program.main(
args=('pull-request',),
path=self.path,
@@ -268,7 +268,7 @@
self.assertEqual(captured.stderr.getvalue(), "Can only 'pull-request' on a native Git repository\n")
def test_none(self):
- with OutputCapture(level=logging.INFO) as captured, mocks.local.Git(), mocks.local.Svn():
+ with OutputCapture(level=logging.INFO) as captured, mocks.local.Git(), mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
self.assertEqual(1, program.main(
args=('pull-request',),
path=self.path,
@@ -276,7 +276,7 @@
self.assertEqual(captured.stderr.getvalue(), "Can only 'pull-request' on a native Git repository\n")
def test_no_modified(self):
- with OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path), mocks.local.Svn():
+ with OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path), mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
self.assertEqual(1, program.main(
args=('pull-request', '-i', 'pr-branch', '-v'),
path=self.path,
@@ -285,7 +285,7 @@
self.assertEqual(captured.stderr.getvalue(), 'No modified files\n')
def test_staged(self):
- with OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path) as repo, mocks.local.Svn():
+ with OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
repo.staged['added.txt'] = 'added'
self.assertEqual(1, program.main(
args=('pull-request', '-i', 'pr-branch', '-v'),
@@ -308,7 +308,7 @@
self.assertEqual(captured.stderr.getvalue(), "'{}' doesn't have a recognized remote\n".format(self.path))
def test_modified(self):
- with OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path) as repo, mocks.local.Svn():
+ with OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
repo.modified['modified.txt'] = 'diff'
self.assertEqual(1, program.main(
args=('pull-request', '-i', 'pr-branch', '-v'),
@@ -335,7 +335,7 @@
with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub() as remote, mocks.local.Git(
self.path, remote='https://{}'.format(remote.remote),
remotes=dict(fork='https://{}/Contributor/WebKit'.format(remote.hosts[0])),
- ) as repo, mocks.local.Svn():
+ ) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
repo.staged['added.txt'] = 'added'
self.assertEqual(0, program.main(
@@ -372,7 +372,7 @@
with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub() as remote, mocks.local.Git(
self.path, remote='https://{}'.format(remote.remote),
remotes=dict(fork='https://{}/Contributor/WebKit'.format(remote.hosts[0])),
- ) as repo, mocks.local.Svn():
+ ) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
repo.staged['added.txt'] = 'added'
self.assertEqual(0, program.main(
@@ -411,7 +411,7 @@
}) as remote, mocks.local.Git(
self.path, remote='https://{}'.format(remote.remote),
remotes=dict(fork='https://{}/Contributor/WebKit'.format(remote.hosts[0])),
- ) as repo, mocks.local.Svn():
+ ) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
with OutputCapture():
repo.staged['added.txt'] = 'added'
self.assertEqual(0, program.main(
@@ -460,7 +460,7 @@
with mocks.remote.GitHub() as remote, mocks.local.Git(
self.path, remote='https://{}'.format(remote.remote),
remotes=dict(fork='https://{}/Contributor/WebKit'.format(remote.hosts[0])),
- ) as repo, mocks.local.Svn():
+ ) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
with OutputCapture():
repo.staged['added.txt'] = 'added'
self.assertEqual(0, program.main(
@@ -503,7 +503,7 @@
with mocks.remote.GitHub() as remote, mocks.local.Git(
self.path, remote='https://{}'.format(remote.remote),
remotes=dict(fork='https://{}/Contributor/WebKit'.format(remote.hosts[0])),
- ) as repo, mocks.local.Svn():
+ ) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
with OutputCapture():
repo.staged['added.txt'] = 'added'
self.assertEqual(0, program.main(
@@ -735,7 +735,7 @@
def test_bitbucket(self):
with OutputCapture(level=logging.INFO) as captured, mocks.remote.BitBucket() as remote, mocks.local.Git(self.path, remote='ssh://git@{}/{}/{}.git'.format(
remote.hosts[0], remote.project.split('/')[1], remote.project.split('/')[3],
- )) as repo, mocks.local.Svn():
+ )) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
repo.staged['added.txt'] = 'added'
self.assertEqual(0, program.main(
@@ -770,7 +770,7 @@
def test_bitbucket_draft(self):
with OutputCapture(level=logging.INFO) as captured, mocks.remote.BitBucket() as remote, mocks.local.Git(self.path, remote='ssh://git@{}/{}/{}.git'.format(
remote.hosts[0], remote.project.split('/')[1], remote.project.split('/')[3],
- )) as repo, mocks.local.Svn():
+ )) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
repo.staged['added.txt'] = 'added'
self.assertEqual(1, program.main(
@@ -804,7 +804,7 @@
def test_bitbucket_update(self):
with mocks.remote.BitBucket() as remote, mocks.local.Git(self.path, remote='ssh://git@{}/{}/{}.git'.format(
remote.hosts[0], remote.project.split('/')[1], remote.project.split('/')[3],
- )) as repo, mocks.local.Svn():
+ )) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
with OutputCapture():
repo.staged['added.txt'] = 'added'
self.assertEqual(0, program.main(
@@ -843,7 +843,7 @@
def test_bitbucket_append(self):
with mocks.remote.BitBucket() as remote, mocks.local.Git(self.path, remote='ssh://git@{}/{}/{}.git'.format(
remote.hosts[0], remote.project.split('/')[1], remote.project.split('/')[3],
- )) as repo, mocks.local.Svn():
+ )) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
with OutputCapture():
repo.staged['added.txt'] = 'added'
self.assertEqual(0, program.main(
@@ -883,7 +883,7 @@
def test_bitbucket_reopen(self):
with mocks.remote.BitBucket() as remote, mocks.local.Git(self.path, remote='ssh://git@{}/{}/{}.git'.format(
remote.hosts[0], remote.project.split('/')[1], remote.project.split('/')[3],
- )) as repo, mocks.local.Svn():
+ )) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
with OutputCapture():
repo.staged['added.txt'] = 'added'
self.assertEqual(0, program.main(
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/revert_unittest.py (293874 => 293875)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/revert_unittest.py 2022-05-06 00:24:01 UTC (rev 293874)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/revert_unittest.py 2022-05-06 00:49:04 UTC (rev 293875)
@@ -24,10 +24,8 @@
import os
from mock import patch
-from webkitbugspy import Tracker, User, bugzilla, radar, mocks as bmocks
-from webkitcorepy import OutputCapture, testing, log as wcplog
-from webkitcorepy.mocks import Terminal as MockTerminal, Environment
-from webkitscmpy import Contributor, Commit, PullRequest, local, program, mocks, remote, log as wsplog
+from webkitcorepy import OutputCapture, testing
+from webkitscmpy import local, program, mocks
class TestRevert(testing.PathTestCase):
@@ -44,7 +42,7 @@
with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub() as remote, mocks.local.Git(
self.path, remote='https://{}'.format(remote.remote),
remotes=dict(fork='https://{}/Contributor/WebKit'.format(remote.hosts[0])),
- ) as repo, mocks.local.Svn():
+ ) as repo, mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
result = program.main(
args=('revert', 'd8bce26fa65c6fc8f39c17927abb77f69fab82fc', '-i', 'pr-branch', '-v', '--no-history'),
@@ -83,7 +81,8 @@
def test_modified(self):
with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub() as remote, \
- mocks.local.Git(self.path, remote='https://{}'.format(remote.remote)) as repo, mocks.local.Svn():
+ mocks.local.Git(self.path, remote='https://{}'.format(remote.remote)) as repo, mocks.local.Svn(), \
+ patch('webkitbugspy.Tracker._trackers', []):
repo.modified = {
'a.py': """diff --git a/a.py b/a.py
@@ -106,11 +105,10 @@
self.assertEqual(captured.stderr.getvalue(), 'Please commit your changes or stash them before you revert commit: d8bce26fa65c6fc8f39c17927abb77f69fab82fc')
def test_update(self):
- self.maxDiff = None
with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub() as remote, mocks.local.Git(
self.path, remote='https://{}'.format(remote.remote),
remotes=dict(fork='https://{}/Contributor/WebKit'.format(remote.hosts[0])),
- ) as repo, mocks.local.Svn():
+ ), mocks.local.Svn(), patch('webkitbugspy.Tracker._trackers', []):
result = program.main(
args=('revert', 'd8bce26fa65c6fc8f39c17927abb77f69fab82fc', '-i', 'pr-branch', '-v'),