Modify the config yielded by this context to write to .pre-commit-config.yaml
(path='.', commit=True)
| 67 | |
| 68 | @contextlib.contextmanager |
| 69 | def modify_config(path='.', commit=True): |
| 70 | """Modify the config yielded by this context to write to |
| 71 | .pre-commit-config.yaml |
| 72 | """ |
| 73 | config_path = os.path.join(path, C.CONFIG_FILE) |
| 74 | with open(config_path) as f: |
| 75 | config = yaml_load(f.read()) |
| 76 | yield config |
| 77 | with open(config_path, 'w', encoding='UTF-8') as config_file: |
| 78 | config_file.write(yaml_dump(config)) |
| 79 | if commit: |
| 80 | git_commit(msg=modify_config.__name__, cwd=path) |
| 81 | |
| 82 | |
| 83 | def sample_local_config(): |