[presubmit] Force read files as UTF-8

The avoids the Windows default of using ANSI.

Change-Id: I1a6177729bb4e2453522e763b490396b2f930a42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355741
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Johnni Winther
2024-03-05 14:25:09 +00:00
committed by Commit Queue
parent c0e089af45
commit 2553a65425
+2 -2
View File
@@ -129,7 +129,7 @@ def _CheckDartFormat(input_api, output_api):
# them.
def skip_file(path):
if path.endswith('_test.dart'):
with open(path) as f:
with open(path, encoding='utf-8') as f:
contents = f.read()
if '//#' in contents:
return True
@@ -427,7 +427,7 @@ def _CheckCopyrightYear(input_api, output_api):
path = f.LocalPath()
if (is_dart_file(path) or is_cpp_file(path)
) and f.Action() == 'A' and os.path.isfile(path):
with open(path) as f:
with open(path, encoding='utf-8') as f:
first_line = f.readline()
if 'Copyright' in first_line and year not in first_line:
files.append(path)