Commit 61c0a31a authored by qyearsley's avatar qyearsley Committed by Commit bot

Add back use of --auth-refresh-token-json for wpt-import

This is required for authentication with buildbucket currently,
and thus required for triggering try jobs, see http://crbug.com/693792

BUG=693792

Review-Url: https://codereview.chromium.org/2715093002
Cr-Commit-Position: refs/heads/master@{#453271}
parent e0ececae
...@@ -16,16 +16,23 @@ from webkitpy.common.net.buildbot import Build, filter_latest_builds ...@@ -16,16 +16,23 @@ from webkitpy.common.net.buildbot import Build, filter_latest_builds
_log = logging.getLogger(__name__) _log = logging.getLogger(__name__)
# A refresh token may be needed for some commands, such as git cl try,
# in order to authenticate with buildbucket.
_COMMANDS_THAT_TAKE_REFRESH_TOKEN = ('try',)
class GitCL(object): class GitCL(object):
def __init__(self, host, cwd=None): def __init__(self, host, auth_refresh_token_json=None, cwd=None):
self._host = host self._host = host
self._auth_refresh_token_json = auth_refresh_token_json
self._cwd = cwd self._cwd = cwd
def run(self, args): def run(self, args):
"""Runs git-cl with the given arguments and returns the output.""" """Runs git-cl with the given arguments and returns the output."""
command = ['git', 'cl'] + args command = ['git', 'cl'] + args
if self._auth_refresh_token_json and args[0] in _COMMANDS_THAT_TAKE_REFRESH_TOKEN:
command += ['--auth-refresh-token-json', self._auth_refresh_token_json]
return self._host.executive.run_command(command, cwd=self._cwd) return self._host.executive.run_command(command, cwd=self._cwd)
def get_issue_number(self): def get_issue_number(self):
......
...@@ -20,12 +20,21 @@ class GitCLTest(unittest.TestCase): ...@@ -20,12 +20,21 @@ class GitCLTest(unittest.TestCase):
self.assertEqual(output, 'mock-output') self.assertEqual(output, 'mock-output')
self.assertEqual(host.executive.calls, [['git', 'cl', 'command']]) self.assertEqual(host.executive.calls, [['git', 'cl', 'command']])
def test_run_basic(self): def test_run_with_auth(self):
host = MockHost() host = MockHost()
host.executive = MockExecutive(output='mock-output') host.executive = MockExecutive(output='mock-output')
git_cl = GitCL(host) git_cl = GitCL(host, auth_refresh_token_json='token.json')
git_cl.run(['upload']) git_cl.run(['try', '-b', 'win10_blink_rel'])
self.assertEqual(host.executive.calls, [['git', 'cl', 'upload']]) self.assertEqual(
host.executive.calls,
[['git', 'cl', 'try', '-b', 'win10_blink_rel', '--auth-refresh-token-json', 'token.json']])
def test_some_commands_not_run_with_auth(self):
host = MockHost()
host.executive = MockExecutive(output='mock-output')
git_cl = GitCL(host, auth_refresh_token_json='token.json')
git_cl.run(['issue'])
self.assertEqual(host.executive.calls, [['git', 'cl', 'issue']])
def test_get_issue_number(self): def test_get_issue_number(self):
host = MockHost() host = MockHost()
......
...@@ -55,7 +55,7 @@ class TestImporter(object): ...@@ -55,7 +55,7 @@ class TestImporter(object):
if not self.checkout_is_okay(options.allow_local_commits): if not self.checkout_is_okay(options.allow_local_commits):
return 1 return 1
self.git_cl = GitCL(self.host) self.git_cl = GitCL(self.host, auth_refresh_token_json=options.auth_refresh_token_json)
_log.debug('Noting the current Chromium commit.') _log.debug('Noting the current Chromium commit.')
_, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) _, show_ref_output = self.run(['git', 'show-ref', 'HEAD'])
...@@ -124,7 +124,9 @@ class TestImporter(object): ...@@ -124,7 +124,9 @@ class TestImporter(object):
parser.add_argument('--auto-update', action='store_true', parser.add_argument('--auto-update', action='store_true',
help='uploads CL and initiates commit queue.') help='uploads CL and initiates commit queue.')
parser.add_argument('--auth-refresh-token-json', parser.add_argument('--auth-refresh-token-json',
help='Auth refresh JSON token (ignored, deprecated)') help='authentication refresh token JSON file, '
'used for authentication for try jobs, '
'generally not necessary on developer machines')
parser.add_argument('--ignore-exportable-commits', action='store_true', parser.add_argument('--ignore-exportable-commits', action='store_true',
help='Continue even if there are exportable commits that may be overwritten.') help='Continue even if there are exportable commits that may be overwritten.')
return parser.parse_args(argv) return parser.parse_args(argv)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment