Modify the manifest yielded by this context to write to .pre-commit-hooks.yaml.
(path, commit=True)
| 52 | |
| 53 | @contextlib.contextmanager |
| 54 | def modify_manifest(path, commit=True): |
| 55 | """Modify the manifest yielded by this context to write to |
| 56 | .pre-commit-hooks.yaml. |
| 57 | """ |
| 58 | manifest_path = os.path.join(path, C.MANIFEST_FILE) |
| 59 | with open(manifest_path) as f: |
| 60 | manifest = yaml_load(f.read()) |
| 61 | yield manifest |
| 62 | with open(manifest_path, 'w') as manifest_file: |
| 63 | manifest_file.write(yaml_dump(manifest)) |
| 64 | if commit: |
| 65 | git_commit(msg=modify_manifest.__name__, cwd=path) |
| 66 | |
| 67 | |
| 68 | @contextlib.contextmanager |