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.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
9 | 9 |
10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 return self.tree_status_url | 424 return self.tree_status_url |
425 | 425 |
426 def GetViewVCUrl(self): | 426 def GetViewVCUrl(self): |
427 if not self.viewvc_url: | 427 if not self.viewvc_url: |
428 self.viewvc_url = self._GetRietveldConfig('viewvc-url', error_ok=True) | 428 self.viewvc_url = self._GetRietveldConfig('viewvc-url', error_ok=True) |
429 return self.viewvc_url | 429 return self.viewvc_url |
430 | 430 |
431 def GetBugPrefix(self): | 431 def GetBugPrefix(self): |
432 return self._GetRietveldConfig('bug-prefix', error_ok=True) | 432 return self._GetRietveldConfig('bug-prefix', error_ok=True) |
433 | 433 |
| 434 def GetRunPostUploadHook(self): |
| 435 run_post_upload_hook = self._GetRietveldConfig( |
| 436 'run-post-upload-hook', error_ok=True) |
| 437 return run_post_upload_hook == "True" |
| 438 |
434 def GetDefaultCCList(self): | 439 def GetDefaultCCList(self): |
435 return self._GetRietveldConfig('cc', error_ok=True) | 440 return self._GetRietveldConfig('cc', error_ok=True) |
436 | 441 |
437 def GetDefaultPrivateFlag(self): | 442 def GetDefaultPrivateFlag(self): |
438 return self._GetRietveldConfig('private', error_ok=True) | 443 return self._GetRietveldConfig('private', error_ok=True) |
439 | 444 |
440 def GetIsGerrit(self): | 445 def GetIsGerrit(self): |
441 """Return true if this repo is assosiated with gerrit code review system.""" | 446 """Return true if this repo is assosiated with gerrit code review system.""" |
442 if self.is_gerrit is None: | 447 if self.is_gerrit is None: |
443 self.is_gerrit = self._GetConfig('gerrit.host', error_ok=True) | 448 self.is_gerrit = self._GetConfig('gerrit.host', error_ok=True) |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 if new_val != initial: | 1026 if new_val != initial: |
1022 RunGit(['config', 'rietveld.' + name, new_val]) | 1027 RunGit(['config', 'rietveld.' + name, new_val]) |
1023 | 1028 |
1024 SetProperty(settings.GetDefaultCCList(), 'CC list', 'cc', False) | 1029 SetProperty(settings.GetDefaultCCList(), 'CC list', 'cc', False) |
1025 SetProperty(settings.GetDefaultPrivateFlag(), | 1030 SetProperty(settings.GetDefaultPrivateFlag(), |
1026 'Private flag (rietveld only)', 'private', False) | 1031 'Private flag (rietveld only)', 'private', False) |
1027 SetProperty(settings.GetTreeStatusUrl(error_ok=True), 'Tree status URL', | 1032 SetProperty(settings.GetTreeStatusUrl(error_ok=True), 'Tree status URL', |
1028 'tree-status-url', False) | 1033 'tree-status-url', False) |
1029 SetProperty(settings.GetViewVCUrl(), 'ViewVC URL', 'viewvc-url', True) | 1034 SetProperty(settings.GetViewVCUrl(), 'ViewVC URL', 'viewvc-url', True) |
1030 SetProperty(settings.GetBugPrefix(), 'Bug Prefix', 'bug-prefix', False) | 1035 SetProperty(settings.GetBugPrefix(), 'Bug Prefix', 'bug-prefix', False) |
| 1036 SetProperty(settings.GetRunPostUploadHook(), 'Run Post Upload Hook', |
| 1037 'run-post-upload-hook', False) |
1031 | 1038 |
1032 # TODO: configure a default branch to diff against, rather than this | 1039 # TODO: configure a default branch to diff against, rather than this |
1033 # svn-based hackery. | 1040 # svn-based hackery. |
1034 | 1041 |
1035 | 1042 |
1036 class ChangeDescription(object): | 1043 class ChangeDescription(object): |
1037 """Contains a parsed form of the change description.""" | 1044 """Contains a parsed form of the change description.""" |
1038 R_LINE = r'^[ \t]*(TBR|R)[ \t]*=[ \t]*(.*?)[ \t]*$' | 1045 R_LINE = r'^[ \t]*(TBR|R)[ \t]*=[ \t]*(.*?)[ \t]*$' |
1039 BUG_LINE = r'^[ \t]*(BUG)[ \t]*=[ \t]*(.*?)[ \t]*$' | 1046 BUG_LINE = r'^[ \t]*(BUG)[ \t]*=[ \t]*(.*?)[ \t]*$' |
1040 | 1047 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 SetProperty('private', 'PRIVATE', unset_error_ok=True) | 1210 SetProperty('private', 'PRIVATE', unset_error_ok=True) |
1204 SetProperty('tree-status-url', 'STATUS', unset_error_ok=True) | 1211 SetProperty('tree-status-url', 'STATUS', unset_error_ok=True) |
1205 SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True) | 1212 SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True) |
1206 SetProperty('bug-prefix', 'BUG_PREFIX', unset_error_ok=True) | 1213 SetProperty('bug-prefix', 'BUG_PREFIX', unset_error_ok=True) |
1207 SetProperty('cpplint-regex', 'LINT_REGEX', unset_error_ok=True) | 1214 SetProperty('cpplint-regex', 'LINT_REGEX', unset_error_ok=True) |
1208 SetProperty('force-https-commit-url', 'FORCE_HTTPS_COMMIT_URL', | 1215 SetProperty('force-https-commit-url', 'FORCE_HTTPS_COMMIT_URL', |
1209 unset_error_ok=True) | 1216 unset_error_ok=True) |
1210 SetProperty('cpplint-ignore-regex', 'LINT_IGNORE_REGEX', unset_error_ok=True) | 1217 SetProperty('cpplint-ignore-regex', 'LINT_IGNORE_REGEX', unset_error_ok=True) |
1211 SetProperty('project', 'PROJECT', unset_error_ok=True) | 1218 SetProperty('project', 'PROJECT', unset_error_ok=True) |
1212 SetProperty('pending-ref-prefix', 'PENDING_REF_PREFIX', unset_error_ok=True) | 1219 SetProperty('pending-ref-prefix', 'PENDING_REF_PREFIX', unset_error_ok=True) |
| 1220 SetProperty('run-post-upload-hook', 'RUN_POST_UPLOAD_HOOK', |
| 1221 unset_error_ok=True) |
1213 | 1222 |
1214 if 'GERRIT_HOST' in keyvals: | 1223 if 'GERRIT_HOST' in keyvals: |
1215 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) | 1224 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) |
1216 | 1225 |
1217 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: | 1226 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: |
1218 #should be of the form | 1227 #should be of the form |
1219 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof | 1228 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof |
1220 #ORIGIN_URL_CONFIG: http://src.chromium.org/git | 1229 #ORIGIN_URL_CONFIG: http://src.chromium.org/git |
1221 RunGit(['config', keyvals['PUSH_URL_CONFIG'], | 1230 RunGit(['config', keyvals['PUSH_URL_CONFIG'], |
1222 keyvals['ORIGIN_URL_CONFIG']]) | 1231 keyvals['ORIGIN_URL_CONFIG']]) |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 'might not include those changes.') | 2037 'might not include those changes.') |
2029 ask_for_data('About to upload; enter to confirm.') | 2038 ask_for_data('About to upload; enter to confirm.') |
2030 | 2039 |
2031 print_stats(options.similarity, options.find_copies, args) | 2040 print_stats(options.similarity, options.find_copies, args) |
2032 if settings.GetIsGerrit(): | 2041 if settings.GetIsGerrit(): |
2033 return GerritUpload(options, args, cl, change) | 2042 return GerritUpload(options, args, cl, change) |
2034 ret = RietveldUpload(options, args, cl, change) | 2043 ret = RietveldUpload(options, args, cl, change) |
2035 if not ret: | 2044 if not ret: |
2036 git_set_branch_value('last-upload-hash', | 2045 git_set_branch_value('last-upload-hash', |
2037 RunGit(['rev-parse', 'HEAD']).strip()) | 2046 RunGit(['rev-parse', 'HEAD']).strip()) |
| 2047 # Run post upload hooks, if specified. |
| 2048 if settings.GetRunPostUploadHook(): |
| 2049 presubmit_support.DoPostUploadExecuter( |
| 2050 change, |
| 2051 cl, |
| 2052 settings.GetRoot(), |
| 2053 options.verbose, |
| 2054 sys.stdout) |
2038 | 2055 |
2039 return ret | 2056 return ret |
2040 | 2057 |
2041 | 2058 |
2042 def IsSubmoduleMergeCommit(ref): | 2059 def IsSubmoduleMergeCommit(ref): |
2043 # When submodules are added to the repo, we expect there to be a single | 2060 # When submodules are added to the repo, we expect there to be a single |
2044 # non-git-svn merge commit at remote HEAD with a signature comment. | 2061 # non-git-svn merge commit at remote HEAD with a signature comment. |
2045 pattern = '^SVN changes up to revision [0-9]*$' | 2062 pattern = '^SVN changes up to revision [0-9]*$' |
2046 cmd = ['rev-list', '--merges', '--grep=%s' % pattern, '%s^!' % ref] | 2063 cmd = ['rev-list', '--merges', '--grep=%s' % pattern, '%s^!' % ref] |
2047 return RunGit(cmd) != '' | 2064 return RunGit(cmd) != '' |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3044 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 3061 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
3045 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 3062 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
3046 | 3063 |
3047 | 3064 |
3048 if __name__ == '__main__': | 3065 if __name__ == '__main__': |
3049 # These affect sys.stdout so do it outside of main() to simplify mocks in | 3066 # These affect sys.stdout so do it outside of main() to simplify mocks in |
3050 # unit testing. | 3067 # unit testing. |
3051 fix_encoding.fix_encoding() | 3068 fix_encoding.fix_encoding() |
3052 colorama.init() | 3069 colorama.init() |
3053 sys.exit(main(sys.argv[1:])) | 3070 sys.exit(main(sys.argv[1:])) |
OLD | NEW |