OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """A git command for managing a local cache of git repositories.""" | 6 """A git command for managing a local cache of git repositories.""" |
7 | 7 |
8 from __future__ import print_function | 8 from __future__ import print_function |
9 import errno | 9 import errno |
10 import logging | 10 import logging |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 except WinErr: | 136 except WinErr: |
137 pass | 137 pass |
138 | 138 |
139 | 139 |
140 class Mirror(object): | 140 class Mirror(object): |
141 | 141 |
142 git_exe = 'git.bat' if sys.platform.startswith('win') else 'git' | 142 git_exe = 'git.bat' if sys.platform.startswith('win') else 'git' |
143 gsutil_exe = os.path.join( | 143 gsutil_exe = os.path.join( |
144 os.path.dirname(os.path.abspath(__file__)), | 144 os.path.dirname(os.path.abspath(__file__)), |
145 'third_party', 'gsutil', 'gsutil') | 145 'third_party', 'gsutil', 'gsutil') |
146 bootstrap_bucket = 'chromium-git-cache' | |
147 | 146 |
148 def __init__(self, url, refs=None, print_func=None): | 147 def __init__(self, url, refs=None, print_func=None): |
149 self.url = url | 148 self.url = url |
150 self.refs = refs or [] | 149 self.refs = refs or [] |
151 self.basedir = self.UrlToCacheDir(url) | 150 self.basedir = self.UrlToCacheDir(url) |
152 self.mirror_path = os.path.join(self.GetCachePath(), self.basedir) | 151 self.mirror_path = os.path.join(self.GetCachePath(), self.basedir) |
153 self.print = print_func or print | 152 self.print = print_func or print |
154 | 153 |
| 154 @property |
| 155 def bootstrap_bucket(self): |
| 156 if 'chrome-internal' in self.url: |
| 157 return 'chrome-git-cache' |
| 158 else: |
| 159 return 'chromium-git-cache' |
| 160 |
155 @classmethod | 161 @classmethod |
156 def FromPath(cls, path): | 162 def FromPath(cls, path): |
157 return cls(cls.CacheDirToUrl(path)) | 163 return cls(cls.CacheDirToUrl(path)) |
158 | 164 |
159 @staticmethod | 165 @staticmethod |
160 def UrlToCacheDir(url): | 166 def UrlToCacheDir(url): |
161 """Convert a git url to a normalized form for the cache dir path.""" | 167 """Convert a git url to a normalized form for the cache dir path.""" |
162 parsed = urlparse.urlparse(url) | 168 parsed = urlparse.urlparse(url) |
163 norm_url = parsed.netloc + parsed.path | 169 norm_url = parsed.netloc + parsed.path |
164 if norm_url.endswith('.git'): | 170 if norm_url.endswith('.git'): |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 return options, args | 529 return options, args |
524 | 530 |
525 | 531 |
526 def main(argv): | 532 def main(argv): |
527 dispatcher = subcommand.CommandDispatcher(__name__) | 533 dispatcher = subcommand.CommandDispatcher(__name__) |
528 return dispatcher.execute(OptionParser(), argv) | 534 return dispatcher.execute(OptionParser(), argv) |
529 | 535 |
530 | 536 |
531 if __name__ == '__main__': | 537 if __name__ == '__main__': |
532 sys.exit(main(sys.argv[1:])) | 538 sys.exit(main(sys.argv[1:])) |
OLD | NEW |