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

Function migrate_config

pre_commit/commands/migrate_config.py:114–135  ·  view source on GitHub ↗
(config_file: str, quiet: bool = False)

Source from the content-addressed store, hash-verified

112
113
114def migrate_config(config_file: str, quiet: bool = False) -> int:
115 with open(config_file) as f:
116 orig_contents = contents = f.read()
117
118 with cfgv.reraise_as(InvalidConfigError):
119 with cfgv.validate_context(f'File {config_file}'):
120 try:
121 yaml_load(orig_contents)
122 except Exception as e:
123 raise cfgv.ValidationError(str(e))
124
125 contents = _migrate_map(contents)
126 contents = _migrate_composed(contents)
127
128 if contents != orig_contents:
129 with open(config_file, 'w') as f:
130 f.write(contents)
131
132 print('Configuration has been migrated.')
133 elif not quiet:
134 print('Configuration is already migrated.')
135 return 0

Calls 2

_migrate_mapFunction · 0.85
_migrate_composedFunction · 0.85