Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Enables directory-specific presubmit checks to run at upload and/or commit. | 6 """Enables directory-specific presubmit checks to run at upload and/or commit. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 __version__ = '1.8.0' | 9 __version__ = '1.8.0' |
| 10 | 10 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 if 'real_description' not in rev_info: | 237 if 'real_description' not in rev_info: |
| 238 rev_info['real_description'] = ( | 238 rev_info['real_description'] = ( |
| 239 gerrit_util.GetChangeDescriptionFromGitiles( | 239 gerrit_util.GetChangeDescriptionFromGitiles( |
| 240 rev_info['fetch']['http']['url'], rev)) | 240 rev_info['fetch']['http']['url'], rev)) |
| 241 return rev_info['real_description'] | 241 return rev_info['real_description'] |
| 242 | 242 |
| 243 def GetChangeOwner(self, issue): | 243 def GetChangeOwner(self, issue): |
| 244 return self.GetChangeInfo(issue)['owner']['email'] | 244 return self.GetChangeInfo(issue)['owner']['email'] |
| 245 | 245 |
| 246 def GetChangeReviewers(self, issue, approving_only=True): | 246 def GetChangeReviewers(self, issue, approving_only=True): |
| 247 # Gerrit has 'approved' sub-section, but it only lists 1 approver. | 247 cr = self.GetChangeInfo(issue)['labels']['Code-Review'] |
| 248 # So, if we look only for approvers, we have to look at all anyway. | 248 max_value = max(int(k) for k in cr['values'].keys()) |
| 249 # Also, assume LGTM means Code-Review label == 2. Other configurations | |
| 250 # aren't supported. | |
| 251 return [r['email'] | 249 return [r['email'] |
| 252 for r in self.GetChangeInfo(issue)['labels']['Code-Review']['all'] | 250 for r in self.GetChangeInfo(issue)['labels']['Code-Review']['all'] |
|
martiniss
2016/07/22 21:41:16
Use cr here?
agable
2016/07/22 21:43:40
Right, fixed.
| |
| 253 if not approving_only or '2' == str(r.get('value', 0))] | 251 if not approving_only or r.get('value', 0) == max_value] |
| 254 | 252 |
| 255 | 253 |
| 256 class OutputApi(object): | 254 class OutputApi(object): |
| 257 """An instance of OutputApi gets passed to presubmit scripts so that they | 255 """An instance of OutputApi gets passed to presubmit scripts so that they |
| 258 can output various types of results. | 256 can output various types of results. |
| 259 """ | 257 """ |
| 260 PresubmitResult = _PresubmitResult | 258 PresubmitResult = _PresubmitResult |
| 261 PresubmitError = _PresubmitError | 259 PresubmitError = _PresubmitError |
| 262 PresubmitPromptWarning = _PresubmitPromptWarning | 260 PresubmitPromptWarning = _PresubmitPromptWarning |
| 263 PresubmitNotifyResult = _PresubmitNotifyResult | 261 PresubmitNotifyResult = _PresubmitNotifyResult |
| (...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1823 return 2 | 1821 return 2 |
| 1824 | 1822 |
| 1825 | 1823 |
| 1826 if __name__ == '__main__': | 1824 if __name__ == '__main__': |
| 1827 fix_encoding.fix_encoding() | 1825 fix_encoding.fix_encoding() |
| 1828 try: | 1826 try: |
| 1829 sys.exit(main()) | 1827 sys.exit(main()) |
| 1830 except KeyboardInterrupt: | 1828 except KeyboardInterrupt: |
| 1831 sys.stderr.write('interrupted\n') | 1829 sys.stderr.write('interrupted\n') |
| 1832 sys.exit(2) | 1830 sys.exit(2) |
| OLD | NEW |