Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: presubmit_support.py

Issue 2178673002: Have presubmit accept various Code-Review label configurations (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Tests and comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 249 return [r['email'] for r in cr['all']
250 # aren't supported. 250 if not approving_only or r.get('value', 0) == max_value]
251 return [r['email']
252 for r in self.GetChangeInfo(issue)['labels']['Code-Review']['all']
253 if not approving_only or '2' == str(r.get('value', 0))]
254 251
255 252
256 class OutputApi(object): 253 class OutputApi(object):
257 """An instance of OutputApi gets passed to presubmit scripts so that they 254 """An instance of OutputApi gets passed to presubmit scripts so that they
258 can output various types of results. 255 can output various types of results.
259 """ 256 """
260 PresubmitResult = _PresubmitResult 257 PresubmitResult = _PresubmitResult
261 PresubmitError = _PresubmitError 258 PresubmitError = _PresubmitError
262 PresubmitPromptWarning = _PresubmitPromptWarning 259 PresubmitPromptWarning = _PresubmitPromptWarning
263 PresubmitNotifyResult = _PresubmitNotifyResult 260 PresubmitNotifyResult = _PresubmitNotifyResult
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 return 2 1820 return 2
1824 1821
1825 1822
1826 if __name__ == '__main__': 1823 if __name__ == '__main__':
1827 fix_encoding.fix_encoding() 1824 fix_encoding.fix_encoding()
1828 try: 1825 try:
1829 sys.exit(main()) 1826 sys.exit(main())
1830 except KeyboardInterrupt: 1827 except KeyboardInterrupt:
1831 sys.stderr.write('interrupted\n') 1828 sys.stderr.write('interrupted\n')
1832 sys.exit(2) 1829 sys.exit(2)
OLDNEW
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698