| 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 from webkitpy.common.checkout.git import Git |
| 16 | 17 |
| 17 _log = logging.getLogger(__name__) | 18 _log = logging.getLogger(__name__) |
| 18 | 19 |
| 19 # A refresh token may be needed for some commands, such as git cl try, | 20 # A refresh token may be needed for some commands, such as git cl try, |
| 20 # in order to authenticate with buildbucket. | 21 # in order to authenticate with buildbucket. |
| 21 _COMMANDS_THAT_TAKE_REFRESH_TOKEN = ('try',) | 22 _COMMANDS_THAT_TAKE_REFRESH_TOKEN = ('try',) |
| 22 | 23 |
| 23 | 24 |
| 24 class GitCL(object): | 25 class GitCL(object): |
| 25 | 26 |
| 26 def __init__(self, host, auth_refresh_token_json=None, cwd=None): | 27 def __init__(self, host, auth_refresh_token_json=None, cwd=None): |
| 27 self._host = host | 28 self._host = host |
| 28 self._auth_refresh_token_json = auth_refresh_token_json | 29 self._auth_refresh_token_json = auth_refresh_token_json |
| 29 self._cwd = cwd | 30 self._cwd = cwd |
| 31 self._git_executable_name = Git.find_executable_name(host.executive, hos
t.platform) |
| 30 | 32 |
| 31 def run(self, args): | 33 def run(self, args): |
| 32 """Runs git-cl with the given arguments and returns the output.""" | 34 """Runs git-cl with the given arguments and returns the output.""" |
| 33 command = ['git', 'cl'] + args | 35 command = [self._git_executable_name, 'cl'] + args |
| 34 if self._auth_refresh_token_json and args[0] in _COMMANDS_THAT_TAKE_REFR
ESH_TOKEN: | 36 if self._auth_refresh_token_json and args[0] in _COMMANDS_THAT_TAKE_REFR
ESH_TOKEN: |
| 35 command += ['--auth-refresh-token-json', self._auth_refresh_token_js
on] | 37 command += ['--auth-refresh-token-json', self._auth_refresh_token_js
on] |
| 36 return self._host.executive.run_command(command, cwd=self._cwd) | 38 return self._host.executive.run_command(command, cwd=self._cwd) |
| 37 | 39 |
| 38 def trigger_try_jobs(self, builders=None): | 40 def trigger_try_jobs(self, builders=None): |
| 39 builders = builders or self._host.builders.all_try_builder_names() | 41 builders = builders or self._host.builders.all_try_builder_names() |
| 40 if 'android_blink_rel' in builders: | 42 if 'android_blink_rel' in builders: |
| 41 self.run(['try', '-b', 'android_blink_rel']) | 43 self.run(['try', '-b', 'android_blink_rel']) |
| 42 builders.remove('android_blink_rel') | 44 builders.remove('android_blink_rel') |
| 43 # TODO(qyearsley): Stop explicitly adding the master name when | 45 # TODO(qyearsley): Stop explicitly adding the master name when |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 assert build_number and build_number.isdigit() | 117 assert build_number and build_number.isdigit() |
| 116 return Build(builder_name, int(build_number)) | 118 return Build(builder_name, int(build_number)) |
| 117 | 119 |
| 118 @staticmethod | 120 @staticmethod |
| 119 def all_jobs_finished(try_results): | 121 def all_jobs_finished(try_results): |
| 120 return all(r.get('status') == 'COMPLETED' for r in try_results) | 122 return all(r.get('status') == 'COMPLETED' for r in try_results) |
| 121 | 123 |
| 122 @staticmethod | 124 @staticmethod |
| 123 def has_failing_try_results(try_results): | 125 def has_failing_try_results(try_results): |
| 124 return any(r.get('result') == 'FAILURE' for r in try_results) | 126 return any(r.get('result') == 'FAILURE' for r in try_results) |
| OLD | NEW |