Skip to content

Commit

Permalink
Cherry-pick 266526@main (7072a0c). rdar://112268906
Browse files Browse the repository at this point in the history
    [git-webkit] no-issue should disable radar CC
    https://bugs.webkit.org/show_bug.cgi?id=259214
    rdar://112268906

    Reviewed by Dewei Zhu and Ryan Haddad.

    * Tools/Scripts/libraries/webkitscmpy/setup.py: Bump version.
    * Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
    * Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
    (PullRequest.create_pull_request): Disable radar CC when not updating an issue.
    * Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:

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

Canonical link: https://commits.webkit.org/265870.400@safari-7616-branch
  • Loading branch information
JonWBedard committed Aug 21, 2023
1 parent cfdf42e commit de8de70
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Tools/Scripts/libraries/webkitscmpy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def readme():

setup(
name='webkitscmpy',
version='6.6.4',
version='6.6.5',
description='Library designed to interact with git and svn repositories.',
long_description=readme(),
classifiers=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _maybe_add_webkitcorepy_path():
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)

version = Version(6, 6, 4)
version = Version(6, 6, 5)

AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
AutoInstall.register(Package('jinja2', Version(2, 11, 3)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def create_pull_request(cls, repository, args, branch_point, callback=None, unbl
radar_issue = next(iter(filter(lambda issue: isinstance(issue.tracker, radar.Tracker), issues)), None)
not_radar = next(iter(filter(lambda issue: not isinstance(issue.tracker, radar.Tracker), issues)), None)
radar_cc_default = repository.config().get('webkitscmpy.cc-radar', 'true') == 'true'
if radar_issue and not_radar and radar_issue.tracker.radarclient() and (args.cc_radar or (radar_cc_default and args.cc_radar is not False)):
if update_issue and radar_issue and not_radar and radar_issue.tracker.radarclient() and (args.cc_radar or (radar_cc_default and args.cc_radar is not False)):
not_radar.cc_radar(radar=radar_issue)

redaction_exemption = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,72 @@ def test_no_cc_radar(self):
],
)

def test_no_update_issue(self):
with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub(projects=bmocks.PROJECTS) as remote, bmocks.Bugzilla(
self.BUGZILLA.split('://')[-1],
projects=bmocks.PROJECTS, issues=bmocks.ISSUES,
environment=Environment(
BUGS_EXAMPLE_COM_USERNAME='tcontributor@example.com',
BUGS_EXAMPLE_COM_PASSWORD='password',
),
), bmocks.Radar(issues=bmocks.ISSUES), patch(
'webkitbugspy.Tracker._trackers', [
bugzilla.Tracker(self.BUGZILLA, radar_importer=bmocks.USERS['Radar WebKit Bug Importer']),
radar.Tracker(),
],
), 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():
repo.commits['eng/pr-branch'] = [
repo.commits[repo.default_branch][-1],
Commit(
hash='06de5d56554e693db72313f4ca1fb969c30b8ccb',
branch='eng/pr-branch',
author=dict(name='Tim Contributor', emails=['tcontributor@example.com']),
identifier="5.1@eng/pr-branch",
timestamp=int(time.time()),
message='[Testing] Existing commit\nbugs.example.com/show_bug.cgi?id=1\n<rdar://problem/1>\n'
)
]
repo.head = repo.commits['eng/pr-branch'][-1]
self.assertEqual(0, program.main(
args=('pull-request', '-v', '--no-history', '--no-issue'),
path=self.path,
))

self.assertEqual(
Tracker.instance().issue(1).comments[-1].content,
'Trying to prepare a fix for 1.2.4',
)
gh_issue = github.Tracker('https://github.example.com/WebKit/WebKit').issue(1)
self.assertEqual(gh_issue.project, 'WebKit')
self.assertEqual(gh_issue.component, 'Text')

self.assertEqual(
captured.stdout.getvalue(),
"Created 'PR 1 | [Testing] Existing commit'!\n"
'https://github.example.com/WebKit/WebKit/pull/1\n',
)
self.assertEqual(captured.stderr.getvalue(), '')
log = captured.root.log.getvalue().splitlines()
self.assertEqual(
[line for line in log if 'Mock process' not in line], [
"Using committed changes...",
"Rebasing 'eng/pr-branch' on 'main'...",
"Rebased 'eng/pr-branch' on 'main!'",
'Running pre-PR checks...',
'No pre-PR checks to run',
'Checking if PR already exists...',
'PR not found.',
"Updating 'main' on 'https://github.example.com/Contributor/WebKit'",
"Pushing 'eng/pr-branch' to 'fork'...",
"Creating pull-request for 'eng/pr-branch'...",
'Syncing PR labels with issue component...',
'Synced PR labels with issue component!',
],
)

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],
Expand Down

0 comments on commit de8de70

Please sign in to comment.