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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 # pylint complains. | 417 # pylint complains. |
418 self.print('Error moving %s to %s: %s' % (tempdir, self.mirror_path, | 418 self.print('Error moving %s to %s: %s' % (tempdir, self.mirror_path, |
419 str(e))) | 419 str(e))) |
420 if not ignore_lock: | 420 if not ignore_lock: |
421 lockfile.unlock() | 421 lockfile.unlock() |
422 | 422 |
423 def update_bootstrap(self, prune=False): | 423 def update_bootstrap(self, prune=False): |
424 # The files are named <git number>.zip | 424 # The files are named <git number>.zip |
425 gen_number = subprocess.check_output( | 425 gen_number = subprocess.check_output( |
426 [self.git_exe, 'number', 'master'], cwd=self.mirror_path).strip() | 426 [self.git_exe, 'number', 'master'], cwd=self.mirror_path).strip() |
427 self.RunGit(['gc']) # Run Garbage Collect to compress packfile. | 427 # Run Garbage Collect to compress packfile. |
| 428 self.RunGit(['gc', '--prune=all']) |
428 # Creating a temp file and then deleting it ensures we can use this name. | 429 # Creating a temp file and then deleting it ensures we can use this name. |
429 _, tmp_zipfile = tempfile.mkstemp(suffix='.zip') | 430 _, tmp_zipfile = tempfile.mkstemp(suffix='.zip') |
430 os.remove(tmp_zipfile) | 431 os.remove(tmp_zipfile) |
431 subprocess.call(['zip', '-r', tmp_zipfile, '.'], cwd=self.mirror_path) | 432 subprocess.call(['zip', '-r', tmp_zipfile, '.'], cwd=self.mirror_path) |
432 gsutil = Gsutil(path=self.gsutil_exe, boto_path=None) | 433 gsutil = Gsutil(path=self.gsutil_exe, boto_path=None) |
433 gs_folder = 'gs://%s/%s' % (self.bootstrap_bucket, self.basedir) | 434 gs_folder = 'gs://%s/%s' % (self.bootstrap_bucket, self.basedir) |
434 dest_name = '%s/%s.zip' % (gs_folder, gen_number) | 435 dest_name = '%s/%s.zip' % (gs_folder, gen_number) |
435 gsutil.call('cp', tmp_zipfile, dest_name) | 436 gsutil.call('cp', tmp_zipfile, dest_name) |
436 os.remove(tmp_zipfile) | 437 os.remove(tmp_zipfile) |
437 | 438 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 return options, args | 685 return options, args |
685 | 686 |
686 | 687 |
687 def main(argv): | 688 def main(argv): |
688 dispatcher = subcommand.CommandDispatcher(__name__) | 689 dispatcher = subcommand.CommandDispatcher(__name__) |
689 return dispatcher.execute(OptionParser(), argv) | 690 return dispatcher.execute(OptionParser(), argv) |
690 | 691 |
691 | 692 |
692 if __name__ == '__main__': | 693 if __name__ == '__main__': |
693 sys.exit(main(sys.argv[1:])) | 694 sys.exit(main(sys.argv[1:])) |
OLD | NEW |