| OLD | NEW |
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 from __future__ import print_function | 5 from __future__ import print_function |
| 6 | 6 |
| 7 import contextlib | 7 import contextlib |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import shutil | 10 import shutil |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 finally: | 29 finally: |
| 30 if workdir_tempdir: | 30 if workdir_tempdir: |
| 31 shutil.rmtree(args.workdir, ignore_errors=True) | 31 shutil.rmtree(args.workdir, ignore_errors=True) |
| 32 | 32 |
| 33 | 33 |
| 34 def main(args): | 34 def main(args): |
| 35 with ensure_workdir(args): | 35 with ensure_workdir(args): |
| 36 checkout_dir = os.path.join(args.workdir, 'checkout') | 36 checkout_dir = os.path.join(args.workdir, 'checkout') |
| 37 if args.use_gitiles: | 37 if args.use_gitiles: |
| 38 args.revision = args.revision or 'HEAD' | 38 args.revision = args.revision or 'HEAD' |
| 39 fetch.ensure_gitiles_checkout( | 39 backend = fetch.GitilesBackend() |
| 40 args.repository, args.revision, checkout_dir, allow_fetch=True) | |
| 41 else: | 40 else: |
| 42 args.revision = args.revision or 'FETCH_HEAD' | 41 args.revision = args.revision or 'FETCH_HEAD' |
| 43 fetch.ensure_git_checkout( | 42 backend = fetch.GitBackend() |
| 44 args.repository, args.revision, checkout_dir, allow_fetch=True) | 43 backend.checkout( |
| 44 args.repository, args.revision, checkout_dir, allow_fetch=True) |
| 45 recipes_cfg = package.ProtoFile( | 45 recipes_cfg = package.ProtoFile( |
| 46 package.InfraRepoConfig().to_recipes_cfg(checkout_dir)) | 46 package.InfraRepoConfig().to_recipes_cfg(checkout_dir)) |
| 47 cmd = [ | 47 cmd = [ |
| 48 sys.executable, | 48 sys.executable, |
| 49 os.path.join( | 49 os.path.join( |
| 50 checkout_dir, | 50 checkout_dir, |
| 51 recipes_cfg.read().recipes_path, | 51 recipes_cfg.read().recipes_path, |
| 52 'recipes.py'), | 52 'recipes.py'), |
| 53 'run' | 53 'run' |
| 54 ] + args.run_args | 54 ] + args.run_args |
| 55 logging.info('Running %r', cmd) | 55 logging.info('Running %r', cmd) |
| 56 return subprocess.call(cmd) | 56 return subprocess.call(cmd) |
| OLD | NEW |