(repo_path, rev=None, hooks=None, check=True)
| 97 | |
| 98 | |
| 99 | def make_config_from_repo(repo_path, rev=None, hooks=None, check=True): |
| 100 | manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE)) |
| 101 | config = { |
| 102 | 'repo': f'file://{repo_path}', |
| 103 | 'rev': rev or git.head_rev(repo_path), |
| 104 | 'hooks': hooks or [{'id': hook['id']} for hook in manifest], |
| 105 | } |
| 106 | |
| 107 | if check: |
| 108 | wrapped = validate({'repos': [config]}, CONFIG_SCHEMA) |
| 109 | wrapped = apply_defaults(wrapped, CONFIG_SCHEMA) |
| 110 | config, = wrapped['repos'] |
| 111 | return config |
| 112 | else: |
| 113 | return config |
| 114 | |
| 115 | |
| 116 | def read_config(directory, config_file=C.CONFIG_FILE): |
no outgoing calls