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

Unified Diff: git_cache.py

Issue 337763005: Allow pruning other files when uploading bootstrap tarball (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cache.py
diff --git a/git_cache.py b/git_cache.py
index 9ade6746363eb9455327ec97483fa7581ab950d6..73c91125682cd672c38684ea049dbfae6848af2b 100755
--- a/git_cache.py
+++ b/git_cache.py
@@ -346,7 +346,7 @@ class Mirror(object):
if tempdir:
os.rename(tempdir, self.mirror_path)
- def update_bootstrap(self):
+ def update_bootstrap(self, prune=False):
# The files are named <git number>.zip
gen_number = subprocess.check_output(
[self.git_exe, 'number', 'master'], cwd=self.mirror_path).strip()
@@ -356,11 +356,19 @@ class Mirror(object):
os.remove(tmp_zipfile)
subprocess.call(['zip', '-r', tmp_zipfile, '.'], cwd=self.mirror_path)
gsutil = Gsutil(path=self.gsutil_exe, boto_path=None)
- dest_name = 'gs://%s/%s/%s.zip' % (
- self.bootstrap_bucket, self.basedir, gen_number)
+ gs_folder = 'gs://%s/%s' % (self.bootstrap_bucket, self.basedir)
+ dest_name = '%s/%s.zip' % (gs_folder, gen_number)
gsutil.call('cp', tmp_zipfile, dest_name)
os.remove(tmp_zipfile)
+ # Remove all other files in the same directory.
+ if prune:
+ _, ls_out, _ = gsutil.check_call('ls', gs_folder)
+ for filename in ls_out.splitlines():
+ if filename == dest_name:
+ continue
+ gsutil.call('rm', filename)
+
@staticmethod
def DeleteTmpPackFiles(path):
pack_dir = os.path.join(path, 'objects', 'pack')
@@ -431,16 +439,19 @@ def CMDupdate_bootstrap(parser, args):
print('Sorry, update bootstrap will not work on Windows.', file=sys.stderr)
return 1
+ parser.add_option('--prune', action='store_true',
+ help='Prune all other cached zipballs of the same repo.')
+
# First, we need to ensure the cache is populated.
populate_args = args[:]
populate_args.append('--no_bootstrap')
CMDpopulate(parser, populate_args)
# Get the repo directory.
- _, args = parser.parse_args(args)
+ options, args = parser.parse_args(args)
url = args[0]
mirror = Mirror(url)
- mirror.update_bootstrap()
+ mirror.update_bootstrap(options.prune)
return 0
« 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