MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / try_repo

Function try_repo

pre_commit/commands/try_repo.py:51–77  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

49
50
51def 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)

Callers 7

mainFunction · 0.90
_run_try_repoFunction · 0.90
test_try_repo_bare_repoFunction · 0.90

Calls 5

cloneMethod · 0.95
StoreClass · 0.90
yaml_dumpFunction · 0.90
runFunction · 0.90
_repo_refFunction · 0.85

Tested by 6

_run_try_repoFunction · 0.72
test_try_repo_bare_repoFunction · 0.72