mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 18:11:48 +04:00
Ignore BOM for autoupdate migration
This commit is contained in:
parent
2ac26e221c
commit
c18d2ec0f2
1 changed files with 2 additions and 2 deletions
|
|
@ -39,14 +39,14 @@ def _migrate_sha_to_rev(contents: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def migrate_config(config_file: str, quiet: bool = False) -> int:
|
def migrate_config(config_file: str, quiet: bool = False) -> int:
|
||||||
with open(config_file) as f:
|
with open(config_file, encoding='utf-8-sig') as f:
|
||||||
orig_contents = contents = f.read()
|
orig_contents = contents = f.read()
|
||||||
|
|
||||||
contents = _migrate_map(contents)
|
contents = _migrate_map(contents)
|
||||||
contents = _migrate_sha_to_rev(contents)
|
contents = _migrate_sha_to_rev(contents)
|
||||||
|
|
||||||
if contents != orig_contents:
|
if contents != orig_contents:
|
||||||
with open(config_file, 'w') as f:
|
with open(config_file, 'w', encoding='utf-8') as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
|
|
||||||
print('Configuration has been migrated.')
|
print('Configuration has been migrated.')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue