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

Side by Side Diff: git_cl.py

Issue 1927773002: Reland Implement owners check in presubmit for Gerrit. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@P300
Patch Set: gerrit fix Created 4 years, 7 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 | presubmit_canned_checks.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 # Copyright (C) 2008 Evan Martin <martine@danga.com> 6 # Copyright (C) 2008 Evan Martin <martine@danga.com>
7 7
8 """A git-command for integrating reviews on Rietveld and Gerrit.""" 8 """A git-command for integrating reviews on Rietveld and Gerrit."""
9 9
10 from distutils.version import LooseVersion 10 from distutils.version import LooseVersion
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 def UpdateDescription(self, description): 1310 def UpdateDescription(self, description):
1311 self.description = description 1311 self.description = description
1312 return self._codereview_impl.UpdateDescriptionRemote(description) 1312 return self._codereview_impl.UpdateDescriptionRemote(description)
1313 1313
1314 def RunHook(self, committing, may_prompt, verbose, change): 1314 def RunHook(self, committing, may_prompt, verbose, change):
1315 """Calls sys.exit() if the hook fails; returns a HookResults otherwise.""" 1315 """Calls sys.exit() if the hook fails; returns a HookResults otherwise."""
1316 try: 1316 try:
1317 return presubmit_support.DoPresubmitChecks(change, committing, 1317 return presubmit_support.DoPresubmitChecks(change, committing,
1318 verbose=verbose, output_stream=sys.stdout, input_stream=sys.stdin, 1318 verbose=verbose, output_stream=sys.stdout, input_stream=sys.stdin,
1319 default_presubmit=None, may_prompt=may_prompt, 1319 default_presubmit=None, may_prompt=may_prompt,
1320 rietveld_obj=self._codereview_impl.GetRieveldObjForPresubmit()) 1320 rietveld_obj=self._codereview_impl.GetRieveldObjForPresubmit(),
1321 gerrit_obj=self._codereview_impl.GetGerritObjForPresubmit())
1321 except presubmit_support.PresubmitFailure, e: 1322 except presubmit_support.PresubmitFailure, e:
1322 DieWithError( 1323 DieWithError(
1323 ('%s\nMaybe your depot_tools is out of date?\n' 1324 ('%s\nMaybe your depot_tools is out of date?\n'
1324 'If all fails, contact maruel@') % e) 1325 'If all fails, contact maruel@') % e)
1325 1326
1326 def CMDPatchIssue(self, issue_arg, reject, nocommit, directory): 1327 def CMDPatchIssue(self, issue_arg, reject, nocommit, directory):
1327 """Fetches and applies the issue patch from codereview to local branch.""" 1328 """Fetches and applies the issue patch from codereview to local branch."""
1328 if isinstance(issue_arg, (int, long)) or issue_arg.isdigit(): 1329 if isinstance(issue_arg, (int, long)) or issue_arg.isdigit():
1329 parsed_issue_arg = _ParsedIssueNumberArgument(int(issue_arg)) 1330 parsed_issue_arg = _ParsedIssueNumberArgument(int(issue_arg))
1330 else: 1331 else:
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 1495
1495 def PatchsetSetting(self): 1496 def PatchsetSetting(self):
1496 """Returns name of git config setting which stores issue number.""" 1497 """Returns name of git config setting which stores issue number."""
1497 raise NotImplementedError() 1498 raise NotImplementedError()
1498 1499
1499 def GetRieveldObjForPresubmit(self): 1500 def GetRieveldObjForPresubmit(self):
1500 # This is an unfortunate Rietveld-embeddedness in presubmit. 1501 # This is an unfortunate Rietveld-embeddedness in presubmit.
1501 # For non-Rietveld codereviews, this probably should return a dummy object. 1502 # For non-Rietveld codereviews, this probably should return a dummy object.
1502 raise NotImplementedError() 1503 raise NotImplementedError()
1503 1504
1505 def GetGerritObjForPresubmit(self):
1506 # None is valid return value, otherwise presubmit_support.GerritAccessor.
1507 return None
1508
1504 def UpdateDescriptionRemote(self, description): 1509 def UpdateDescriptionRemote(self, description):
1505 """Update the description on codereview site.""" 1510 """Update the description on codereview site."""
1506 raise NotImplementedError() 1511 raise NotImplementedError()
1507 1512
1508 def CloseIssue(self): 1513 def CloseIssue(self):
1509 """Closes the issue.""" 1514 """Closes the issue."""
1510 raise NotImplementedError() 1515 raise NotImplementedError()
1511 1516
1512 def GetApprovingReviewers(self): 1517 def GetApprovingReviewers(self):
1513 """Returns a list of reviewers approving the change. 1518 """Returns a list of reviewers approving the change.
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 def __getattr__(self, attr): 2105 def __getattr__(self, attr):
2101 print( 2106 print(
2102 'You aren\'t using Rietveld at the moment, but Gerrit.\n' 2107 'You aren\'t using Rietveld at the moment, but Gerrit.\n'
2103 'Using Rietveld in your PRESUBMIT scripts won\'t work.\n' 2108 'Using Rietveld in your PRESUBMIT scripts won\'t work.\n'
2104 'Please, either change your PRESUBIT to not use rietveld_obj.%s,\n' 2109 'Please, either change your PRESUBIT to not use rietveld_obj.%s,\n'
2105 'or use Rietveld for codereview.\n' 2110 'or use Rietveld for codereview.\n'
2106 'See also http://crbug.com/579160.' % attr) 2111 'See also http://crbug.com/579160.' % attr)
2107 raise NotImplementedError() 2112 raise NotImplementedError()
2108 return ThisIsNotRietveldIssue() 2113 return ThisIsNotRietveldIssue()
2109 2114
2115 def GetGerritObjForPresubmit(self):
2116 return presubmit_support.GerritAccessor(self._GetGerritHost())
2117
2110 def GetStatus(self): 2118 def GetStatus(self):
2111 """Apply a rough heuristic to give a simple summary of an issue's review 2119 """Apply a rough heuristic to give a simple summary of an issue's review
2112 or CQ status, assuming adherence to a common workflow. 2120 or CQ status, assuming adherence to a common workflow.
2113 2121
2114 Returns None if no issue for this branch, or one of the following keywords: 2122 Returns None if no issue for this branch, or one of the following keywords:
2115 * 'error' - error from review tool (including deleted issues) 2123 * 'error' - error from review tool (including deleted issues)
2116 * 'unsent' - no reviewers added 2124 * 'unsent' - no reviewers added
2117 * 'waiting' - waiting for review 2125 * 'waiting' - waiting for review
2118 * 'reply' - waiting for owner to reply to review 2126 * 'reply' - waiting for owner to reply to review
2119 * 'not lgtm' - Code-Review -2 from at least one approved reviewer 2127 * 'not lgtm' - Code-Review -2 from at least one approved reviewer
(...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after
4857 if __name__ == '__main__': 4865 if __name__ == '__main__':
4858 # These affect sys.stdout so do it outside of main() to simplify mocks in 4866 # These affect sys.stdout so do it outside of main() to simplify mocks in
4859 # unit testing. 4867 # unit testing.
4860 fix_encoding.fix_encoding() 4868 fix_encoding.fix_encoding()
4861 setup_color.init() 4869 setup_color.init()
4862 try: 4870 try:
4863 sys.exit(main(sys.argv[1:])) 4871 sys.exit(main(sys.argv[1:]))
4864 except KeyboardInterrupt: 4872 except KeyboardInterrupt:
4865 sys.stderr.write('interrupted\n') 4873 sys.stderr.write('interrupted\n')
4866 sys.exit(1) 4874 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | presubmit_canned_checks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698