| 49 | |
| 50 | |
| 51 | def try_repo(args: argparse.Namespace) -> int: |
| 52 | with tempfile.TemporaryDirectory() as tempdir: |
| 53 | repo, ref = _repo_ref(tempdir, args.repo, args.ref) |
| 54 | |
| 55 | store = Store(tempdir) |
| 56 | if args.hook: |
| 57 | hooks = [{'id': args.hook}] |
| 58 | else: |
| 59 | repo_path = store.clone(repo, ref) |
| 60 | manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE)) |
| 61 | manifest = sorted(manifest, key=lambda hook: hook['id']) |
| 62 | hooks = [{'id': hook['id']} for hook in manifest] |
| 63 | |
| 64 | config = {'repos': [{'repo': repo, 'rev': ref, 'hooks': hooks}]} |
| 65 | config_s = yaml_dump(config) |
| 66 | |
| 67 | config_filename = os.path.join(tempdir, C.CONFIG_FILE) |
| 68 | with open(config_filename, 'w') as cfg: |
| 69 | cfg.write(config_s) |
| 70 | |
| 71 | output.write_line('=' * 79) |
| 72 | output.write_line('Using config:') |
| 73 | output.write_line('=' * 79) |
| 74 | output.write(config_s) |
| 75 | output.write_line('=' * 79) |
| 76 | |
| 77 | return run(config_filename, store, args) |