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

Side by Side Diff: git_cache.py

Issue 183813004: Add +refs/tags/*:refs/tags/* to git cache config (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: s/replace-all/add/ Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 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 import errno 8 import errno
9 import logging 9 import logging
10 import optparse 10 import optparse
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 d = ['--depth', '%d' % options.depth] 190 d = ['--depth', '%d' % options.depth]
191 191
192 def _config(directory): 192 def _config(directory):
193 RunGit(['config', 'core.deltaBaseCacheLimit', '2g'], 193 RunGit(['config', 'core.deltaBaseCacheLimit', '2g'],
194 cwd=directory) 194 cwd=directory)
195 RunGit(['config', 'remote.origin.url', NormalizeUrl(url)], 195 RunGit(['config', 'remote.origin.url', NormalizeUrl(url)],
196 cwd=directory) 196 cwd=directory)
197 RunGit(['config', '--replace-all', 'remote.origin.fetch', 197 RunGit(['config', '--replace-all', 'remote.origin.fetch',
198 '+refs/heads/*:refs/heads/*'], 198 '+refs/heads/*:refs/heads/*'],
199 cwd=directory) 199 cwd=directory)
200 RunGit(['config', '--add', 'remote.origin.fetch',
201 '+refs/tags/*:refs/tags/*'],
202 cwd=directory)
200 for ref in options.ref or []: 203 for ref in options.ref or []:
201 ref = ref.rstrip('/') 204 ref = ref.rstrip('/')
202 refspec = '+refs/%s/*:refs/%s/*' % (ref, ref) 205 refspec = '+refs/%s/*:refs/%s/*' % (ref, ref)
203 RunGit(['config', '--add', 'remote.origin.fetch', refspec], 206 RunGit(['config', '--add', 'remote.origin.fetch', refspec],
204 cwd=directory) 207 cwd=directory)
205 208
206 with Lockfile(repo_dir): 209 with Lockfile(repo_dir):
207 # Setup from scratch if the repo is new or is in a bad state. 210 # Setup from scratch if the repo is new or is in a bad state.
208 if not os.path.exists(os.path.join(repo_dir, 'config')): 211 if not os.path.exists(os.path.join(repo_dir, 'config')):
209 gclient_utils.rmtree(repo_dir) 212 gclient_utils.rmtree(repo_dir)
210 tempdir = tempfile.mkdtemp(suffix=UrlToCacheDir(url), 213 tempdir = tempfile.mkdtemp(suffix=UrlToCacheDir(url),
211 dir=options.cache_dir) 214 dir=options.cache_dir)
212 RunGit(['init', '--bare'], cwd=tempdir) 215 RunGit(['init', '--bare'], cwd=tempdir)
213 _config(tempdir) 216 _config(tempdir)
214 fetch_cmd = ['fetch'] + v + d + ['--tags', 'origin'] 217 fetch_cmd = ['fetch'] + v + d + ['origin']
215 RunGit(fetch_cmd, filter_fn=filter_fn, cwd=tempdir, retry=True) 218 RunGit(fetch_cmd, filter_fn=filter_fn, cwd=tempdir, retry=True)
216 os.rename(tempdir, repo_dir) 219 os.rename(tempdir, repo_dir)
217 else: 220 else:
218 _config(repo_dir) 221 _config(repo_dir)
219 if options.depth and os.path.exists(os.path.join(repo_dir, 'shallow')): 222 if options.depth and os.path.exists(os.path.join(repo_dir, 'shallow')):
220 logging.warn('Shallow fetch requested, but repo cache already exists.') 223 logging.warn('Shallow fetch requested, but repo cache already exists.')
221 fetch_cmd = ['fetch'] + v + ['--tags', 'origin'] 224 fetch_cmd = ['fetch'] + v + ['origin']
222 RunGit(fetch_cmd, filter_fn=filter_fn, cwd=repo_dir, retry=True) 225 RunGit(fetch_cmd, filter_fn=filter_fn, cwd=repo_dir, retry=True)
223 226
224 227
225 @subcommand.usage('[url of repo to unlock, or -a|--all]') 228 @subcommand.usage('[url of repo to unlock, or -a|--all]')
226 def CMDunlock(parser, args): 229 def CMDunlock(parser, args):
227 """Unlock one or all repos if their lock files are still around.""" 230 """Unlock one or all repos if their lock files are still around."""
228 parser.add_option('--force', '-f', action='store_true', 231 parser.add_option('--force', '-f', action='store_true',
229 help='Actually perform the action') 232 help='Actually perform the action')
230 parser.add_option('--all', '-a', action='store_true', 233 parser.add_option('--all', '-a', action='store_true',
231 help='Unlock all repository caches') 234 help='Unlock all repository caches')
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return options, args 297 return options, args
295 298
296 299
297 def main(argv): 300 def main(argv):
298 dispatcher = subcommand.CommandDispatcher(__name__) 301 dispatcher = subcommand.CommandDispatcher(__name__)
299 return dispatcher.execute(OptionParser(), argv) 302 return dispatcher.execute(OptionParser(), argv)
300 303
301 304
302 if __name__ == '__main__': 305 if __name__ == '__main__':
303 sys.exit(main(sys.argv[1:])) 306 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698