forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically route PRs to specific remotes
https://bugs.webkit.org/show_bug.cgi?id=242129 rdar://96161931 Reviewed by Jonathan Bedard. * Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py * Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py: (PullRequest.create_pull_request): Canonical link: https://commits.webkit.org/252715@main
- Loading branch information
1 parent
cfafcba
commit 6dffcfd
Showing
2 changed files
with
86 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -686,6 +686,64 @@ def test_github_branch_bugzilla(self): | |
], | ||
) | ||
|
||
def test_github_branch_bugzilla_redacted_to_origin(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='[email protected]', | ||
BUGS_EXAMPLE_COM_PASSWORD='password', | ||
)), patch( | ||
'webkitbugspy.Tracker._trackers', [bugzilla.Tracker(self.BUGZILLA, redact={'.*': True})], | ||
), 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(), MockTerminal.input('y'): | ||
|
||
repo.staged['added.txt'] = 'added' | ||
self.assertEqual(0, program.main( | ||
args=('pull-request', '-i', 'https://bugs.example.com/show_bug.cgi?id=1', '-v', '--no-history', '--remote', 'origin'), | ||
path=self.path, | ||
)) | ||
|
||
self.assertEqual( | ||
Tracker.instance().issue(1).comments[-1].content, | ||
'Pull request: https://github.example.com/WebKit/WebKit/pull/1', | ||
) | ||
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(gh_issue.version, 'Other') | ||
|
||
self.assertEqual( | ||
captured.stdout.getvalue(), | ||
"Created the local development branch 'eng/1'\n" | ||
"Created 'PR 1 | Example issue 1'!\n" | ||
"Posted pull request link to https://bugs.example.com/show_bug.cgi?id=1\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], [ | ||
"Creating the local development branch 'eng/1'...", | ||
'Creating commit...', | ||
"Rebasing 'eng/1' on 'main'...", | ||
"Rebased 'eng/1' on 'main!'", | ||
'Running pre-PR checks...', | ||
'No pre-PR checks to run', | ||
'Checking if PR already exists...', | ||
'PR not found.', | ||
"Pushing 'eng/1' to 'fork'...", | ||
"Syncing 'main' to remote 'fork'", | ||
"Creating pull-request for 'eng/1'...", | ||
'Checking issue assignee...', | ||
'Checking for pull request link in associated issue...', | ||
'Syncing PR labels with issue component...', | ||
'Synced PR labels with issue component!', | ||
], | ||
) | ||
|
||
def test_github_branch_bugzilla_redacted(self): | ||
with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub(projects=bmocks.PROJECTS) as remote, bmocks.Bugzilla( | ||
self.BUGZILLA.split('://')[-1], | ||
|
@@ -698,7 +756,7 @@ def test_github_branch_bugzilla_redacted(self): | |
), 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(), MockTerminal.input('y'): | ||
|
||
repo.staged['added.txt'] = 'added' | ||
self.assertEqual(0, program.main( | ||
|
@@ -718,6 +776,10 @@ def test_github_branch_bugzilla_redacted(self): | |
self.assertEqual( | ||
captured.stdout.getvalue(), | ||
"Created the local development branch 'eng/1'\n" | ||
"Your issue is redacted, diverting to a secure, non-origin remote you have access to.\n" | ||
"Error. You do not have access to a secure, non-origin remote\n" | ||
"Would you like to proceed anyways? \n" | ||
" (Yes/[No]): \n" | ||
"Created 'PR 1 | Example issue 1'!\n" | ||
"Posted pull request link to https://bugs.example.com/show_bug.cgi?id=1\n" | ||
"https://github.example.com/WebKit/WebKit/pull/1\n", | ||
|