| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """An interface to git-cl. | 5 """An interface to git-cl. |
| 6 | 6 |
| 7 The git-cl tool is responsible for communicating with Rietveld, Gerrit, | 7 The git-cl tool is responsible for communicating with Rietveld, Gerrit, |
| 8 and Buildbucket to manage changelists and try jobs associated with them. | 8 and Buildbucket to manage changelists and try jobs associated with them. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import json | 11 import json |
| 12 import logging | 12 import logging |
| 13 import re | 13 import re |
| 14 | 14 |
| 15 from webkitpy.common.net.buildbot import Build, filter_latest_builds | 15 from webkitpy.common.net.buildbot import Build, filter_latest_builds |
| 16 | 16 |
| 17 _log = logging.getLogger(__name__) | 17 _log = logging.getLogger(__name__) |
| 18 | 18 |
| 19 _COMMANDS_THAT_REQUIRE_AUTH = ( | |
| 20 'archive', 'comments', 'commit', 'description', 'diff', 'land', 'lint', 'own
ers', 'patch', | |
| 21 'presubmit', 'set-close', 'set-commit', 'status', 'try-results', 'try', 'upl
oad', | |
| 22 ) | |
| 23 | |
| 24 | 19 |
| 25 class GitCL(object): | 20 class GitCL(object): |
| 26 | 21 |
| 27 def __init__(self, host, auth_refresh_token_json=None, cwd=None): | 22 def __init__(self, host, cwd=None): |
| 28 self._host = host | 23 self._host = host |
| 29 self._auth_refresh_token_json = auth_refresh_token_json | |
| 30 self._cwd = cwd | 24 self._cwd = cwd |
| 31 | 25 |
| 32 def run(self, args): | 26 def run(self, args): |
| 33 """Runs git-cl with the given arguments and returns the output.""" | 27 """Runs git-cl with the given arguments and returns the output.""" |
| 34 command = ['git', 'cl'] + args | 28 command = ['git', 'cl'] + args |
| 35 if self._auth_refresh_token_json and args[0] in _COMMANDS_THAT_REQUIRE_A
UTH: | |
| 36 command += ['--auth-refresh-token-json', self._auth_refresh_token_js
on] | |
| 37 return self._host.executive.run_command(command, cwd=self._cwd) | 29 return self._host.executive.run_command(command, cwd=self._cwd) |
| 38 | 30 |
| 39 def get_issue_number(self): | 31 def get_issue_number(self): |
| 40 return self.run(['issue']).split()[2] | 32 return self.run(['issue']).split()[2] |
| 41 | 33 |
| 42 def wait_for_try_jobs(self, poll_delay_seconds=10 * 60, timeout_seconds=120
* 60): | 34 def wait_for_try_jobs(self, poll_delay_seconds=10 * 60, timeout_seconds=120
* 60): |
| 43 """Waits until all try jobs are finished. | 35 """Waits until all try jobs are finished. |
| 44 | 36 |
| 45 Args: | 37 Args: |
| 46 poll_delay_seconds: Time to wait between fetching results. | 38 poll_delay_seconds: Time to wait between fetching results. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 assert build_number and build_number.isdigit() | 84 assert build_number and build_number.isdigit() |
| 93 return Build(builder_name, int(build_number)) | 85 return Build(builder_name, int(build_number)) |
| 94 | 86 |
| 95 @staticmethod | 87 @staticmethod |
| 96 def all_jobs_finished(try_results): | 88 def all_jobs_finished(try_results): |
| 97 return all(r.get('status') == 'COMPLETED' for r in try_results) | 89 return all(r.get('status') == 'COMPLETED' for r in try_results) |
| 98 | 90 |
| 99 @staticmethod | 91 @staticmethod |
| 100 def has_failing_try_results(try_results): | 92 def has_failing_try_results(try_results): |
| 101 return any(r.get('result') == 'FAILURE' for r in try_results) | 93 return any(r.get('result') == 'FAILURE' for r in try_results) |
| OLD | NEW |