build: fix unicode patch file comparison in git.py (#28454)
This caused some patches to fail incorrectly as the patch file included non-ascii characters, we have to manually convert using the utf8 charset
This commit is contained in:
parent
bdeeabdc3c
commit
ba3b2189ad
1 changed files with 5 additions and 3 deletions
|
@ -307,17 +307,19 @@ def export_patches(repo, out_dir, patch_range=None, dry_run=False):
|
||||||
# exported patch differs from what exists. Report number of mismatched
|
# exported patch differs from what exists. Report number of mismatched
|
||||||
# patches and fail if there's more than one.
|
# patches and fail if there's more than one.
|
||||||
patch_count = 0
|
patch_count = 0
|
||||||
|
bad_patches = []
|
||||||
for patch in patches:
|
for patch in patches:
|
||||||
filename = get_file_name(patch)
|
filename = get_file_name(patch)
|
||||||
filepath = posixpath.join(out_dir, filename)
|
filepath = posixpath.join(out_dir, filename)
|
||||||
existing_patch = io.open(filepath, 'rb').read()
|
existing_patch = unicode(io.open(filepath, 'rb').read(), "utf-8")
|
||||||
formatted_patch = join_patch(patch)
|
formatted_patch = join_patch(patch)
|
||||||
if formatted_patch != existing_patch:
|
if formatted_patch != existing_patch:
|
||||||
patch_count += 1
|
patch_count += 1
|
||||||
|
bad_patches.append(filename)
|
||||||
if patch_count > 0:
|
if patch_count > 0:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"Patches in {} not up to date: {} patches need update\n".format(
|
"Patches in {} not up to date: {} patches need update\n-- {}\n".format(
|
||||||
out_dir, patch_count
|
out_dir, patch_count, "\n-- ".join(bad_patches)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
Loading…
Reference in a new issue