| 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 __future__ import print_function | 10 from __future__ import print_function |
| (...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 # auth_config is Rietveld thing, kept here to preserve interface only. | 2028 # auth_config is Rietveld thing, kept here to preserve interface only. |
| 2029 super(_GerritChangelistImpl, self).__init__(changelist) | 2029 super(_GerritChangelistImpl, self).__init__(changelist) |
| 2030 self._change_id = None | 2030 self._change_id = None |
| 2031 # Lazily cached values. | 2031 # Lazily cached values. |
| 2032 self._gerrit_server = None # e.g. https://chromium-review.googlesource.com | 2032 self._gerrit_server = None # e.g. https://chromium-review.googlesource.com |
| 2033 self._gerrit_host = None # e.g. chromium-review.googlesource.com | 2033 self._gerrit_host = None # e.g. chromium-review.googlesource.com |
| 2034 | 2034 |
| 2035 def _GetGerritHost(self): | 2035 def _GetGerritHost(self): |
| 2036 # Lazy load of configs. | 2036 # Lazy load of configs. |
| 2037 self.GetCodereviewServer() | 2037 self.GetCodereviewServer() |
| 2038 if self._gerrit_host and '.' not in self._gerrit_host: |
| 2039 # Abbreviated domain like "chromium" instead of chromium.googlesource.com. |
| 2040 # This happens for internal stuff http://crbug.com/614312. |
| 2041 parsed = urlparse.urlparse(self.GetRemoteUrl()) |
| 2042 if parsed.scheme == 'sso': |
| 2043 print('WARNING: using non https URLs for remote is likely broken\n' |
| 2044 ' Your current remote is: %s' % self.GetRemoteUrl()) |
| 2045 self._gerrit_host = '%s.googlesource.com' % self._gerrit_host |
| 2046 self._gerrit_server = 'https://%s' % self._gerrit_host |
| 2038 return self._gerrit_host | 2047 return self._gerrit_host |
| 2039 | 2048 |
| 2040 def _GetGitHost(self): | 2049 def _GetGitHost(self): |
| 2041 """Returns git host to be used when uploading change to Gerrit.""" | 2050 """Returns git host to be used when uploading change to Gerrit.""" |
| 2042 return urlparse.urlparse(self.GetRemoteUrl()).netloc | 2051 return urlparse.urlparse(self.GetRemoteUrl()).netloc |
| 2043 | 2052 |
| 2044 def GetCodereviewServer(self): | 2053 def GetCodereviewServer(self): |
| 2045 if not self._gerrit_server: | 2054 if not self._gerrit_server: |
| 2046 # If we're on a branch then get the server potentially associated | 2055 # If we're on a branch then get the server potentially associated |
| 2047 # with that branch. | 2056 # with that branch. |
| (...skipping 2994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5042 if __name__ == '__main__': | 5051 if __name__ == '__main__': |
| 5043 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5052 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 5044 # unit testing. | 5053 # unit testing. |
| 5045 fix_encoding.fix_encoding() | 5054 fix_encoding.fix_encoding() |
| 5046 setup_color.init() | 5055 setup_color.init() |
| 5047 try: | 5056 try: |
| 5048 sys.exit(main(sys.argv[1:])) | 5057 sys.exit(main(sys.argv[1:])) |
| 5049 except KeyboardInterrupt: | 5058 except KeyboardInterrupt: |
| 5050 sys.stderr.write('interrupted\n') | 5059 sys.stderr.write('interrupted\n') |
| 5051 sys.exit(1) | 5060 sys.exit(1) |
| OLD | NEW |