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 # 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 Loading... |
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()) | |
1322 except presubmit_support.PresubmitFailure, e: | 1321 except presubmit_support.PresubmitFailure, e: |
1323 DieWithError( | 1322 DieWithError( |
1324 ('%s\nMaybe your depot_tools is out of date?\n' | 1323 ('%s\nMaybe your depot_tools is out of date?\n' |
1325 'If all fails, contact maruel@') % e) | 1324 'If all fails, contact maruel@') % e) |
1326 | 1325 |
1327 def CMDPatchIssue(self, issue_arg, reject, nocommit, directory): | 1326 def CMDPatchIssue(self, issue_arg, reject, nocommit, directory): |
1328 """Fetches and applies the issue patch from codereview to local branch.""" | 1327 """Fetches and applies the issue patch from codereview to local branch.""" |
1329 if isinstance(issue_arg, (int, long)) or issue_arg.isdigit(): | 1328 if isinstance(issue_arg, (int, long)) or issue_arg.isdigit(): |
1330 parsed_issue_arg = _ParsedIssueNumberArgument(int(issue_arg)) | 1329 parsed_issue_arg = _ParsedIssueNumberArgument(int(issue_arg)) |
1331 else: | 1330 else: |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 | 1494 |
1496 def PatchsetSetting(self): | 1495 def PatchsetSetting(self): |
1497 """Returns name of git config setting which stores issue number.""" | 1496 """Returns name of git config setting which stores issue number.""" |
1498 raise NotImplementedError() | 1497 raise NotImplementedError() |
1499 | 1498 |
1500 def GetRieveldObjForPresubmit(self): | 1499 def GetRieveldObjForPresubmit(self): |
1501 # This is an unfortunate Rietveld-embeddedness in presubmit. | 1500 # This is an unfortunate Rietveld-embeddedness in presubmit. |
1502 # For non-Rietveld codereviews, this probably should return a dummy object. | 1501 # For non-Rietveld codereviews, this probably should return a dummy object. |
1503 raise NotImplementedError() | 1502 raise NotImplementedError() |
1504 | 1503 |
1505 def GetGerritObjForPresubmit(self): | |
1506 # None is valid return value, otherwise presubmit_support.GerritAccessor. | |
1507 return None | |
1508 | |
1509 def UpdateDescriptionRemote(self, description): | 1504 def UpdateDescriptionRemote(self, description): |
1510 """Update the description on codereview site.""" | 1505 """Update the description on codereview site.""" |
1511 raise NotImplementedError() | 1506 raise NotImplementedError() |
1512 | 1507 |
1513 def CloseIssue(self): | 1508 def CloseIssue(self): |
1514 """Closes the issue.""" | 1509 """Closes the issue.""" |
1515 raise NotImplementedError() | 1510 raise NotImplementedError() |
1516 | 1511 |
1517 def GetApprovingReviewers(self): | 1512 def GetApprovingReviewers(self): |
1518 """Returns a list of reviewers approving the change. | 1513 """Returns a list of reviewers approving the change. |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 def __getattr__(self, attr): | 2100 def __getattr__(self, attr): |
2106 print( | 2101 print( |
2107 'You aren\'t using Rietveld at the moment, but Gerrit.\n' | 2102 'You aren\'t using Rietveld at the moment, but Gerrit.\n' |
2108 'Using Rietveld in your PRESUBMIT scripts won\'t work.\n' | 2103 'Using Rietveld in your PRESUBMIT scripts won\'t work.\n' |
2109 'Please, either change your PRESUBIT to not use rietveld_obj.%s,\n' | 2104 'Please, either change your PRESUBIT to not use rietveld_obj.%s,\n' |
2110 'or use Rietveld for codereview.\n' | 2105 'or use Rietveld for codereview.\n' |
2111 'See also http://crbug.com/579160.' % attr) | 2106 'See also http://crbug.com/579160.' % attr) |
2112 raise NotImplementedError() | 2107 raise NotImplementedError() |
2113 return ThisIsNotRietveldIssue() | 2108 return ThisIsNotRietveldIssue() |
2114 | 2109 |
2115 def GetGerritObjForPresubmit(self): | |
2116 return presubmit_support.GerritAccessor(self._GetGerritHost()) | |
2117 | |
2118 def GetStatus(self): | 2110 def GetStatus(self): |
2119 """Apply a rough heuristic to give a simple summary of an issue's review | 2111 """Apply a rough heuristic to give a simple summary of an issue's review |
2120 or CQ status, assuming adherence to a common workflow. | 2112 or CQ status, assuming adherence to a common workflow. |
2121 | 2113 |
2122 Returns None if no issue for this branch, or one of the following keywords: | 2114 Returns None if no issue for this branch, or one of the following keywords: |
2123 * 'error' - error from review tool (including deleted issues) | 2115 * 'error' - error from review tool (including deleted issues) |
2124 * 'unsent' - no reviewers added | 2116 * 'unsent' - no reviewers added |
2125 * 'waiting' - waiting for review | 2117 * 'waiting' - waiting for review |
2126 * 'reply' - waiting for owner to reply to review | 2118 * 'reply' - waiting for owner to reply to review |
2127 * 'not lgtm' - Code-Review -2 from at least one approved reviewer | 2119 * 'not lgtm' - Code-Review -2 from at least one approved reviewer |
(...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4865 if __name__ == '__main__': | 4857 if __name__ == '__main__': |
4866 # These affect sys.stdout so do it outside of main() to simplify mocks in | 4858 # These affect sys.stdout so do it outside of main() to simplify mocks in |
4867 # unit testing. | 4859 # unit testing. |
4868 fix_encoding.fix_encoding() | 4860 fix_encoding.fix_encoding() |
4869 setup_color.init() | 4861 setup_color.init() |
4870 try: | 4862 try: |
4871 sys.exit(main(sys.argv[1:])) | 4863 sys.exit(main(sys.argv[1:])) |
4872 except KeyboardInterrupt: | 4864 except KeyboardInterrupt: |
4873 sys.stderr.write('interrupted\n') | 4865 sys.stderr.write('interrupted\n') |
4874 sys.exit(1) | 4866 sys.exit(1) |
OLD | NEW |