From c18d2ec0f211108357e60c9f9967df58c8dfbbf6 Mon Sep 17 00:00:00 2001 From: Mohammadreza Jafari Date: Sun, 17 Oct 2021 02:57:25 +0330 Subject: [PATCH] Ignore BOM for autoupdate migration --- pre_commit/commands/migrate_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pre_commit/commands/migrate_config.py b/pre_commit/commands/migrate_config.py index fef14cd3..b415dd2f 100644 --- a/pre_commit/commands/migrate_config.py +++ b/pre_commit/commands/migrate_config.py @@ -39,14 +39,14 @@ def _migrate_sha_to_rev(contents: str) -> str: 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() contents = _migrate_map(contents) contents = _migrate_sha_to_rev(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) print('Configuration has been migrated.')