fix: error caused by non UTF-8 characters in git diff

This commit is contained in:
fan-ziqi 2024-07-06 16:41:09 +08:00
parent a1d25d1fef
commit d8903932c8
2 changed files with 2 additions and 1 deletions

View File

@ -29,3 +29,4 @@ Please keep the lists sorted alphabetically.
* Matthijs van der Boon * Matthijs van der Boon
* Mayank Mittal * Mayank Mittal
* Zhang Chong * Zhang Chong
* Ziqi Fan

View File

@ -78,7 +78,7 @@ def store_code_state(logdir, repositories) -> list:
continue continue
# write the diff file # write the diff file
print(f"Storing git diff for '{repo_name}' in: {diff_file_name}") print(f"Storing git diff for '{repo_name}' in: {diff_file_name}")
with open(diff_file_name, "x") as f: with open(diff_file_name, "x", encoding="utf-8") as f:
content = f"--- git status ---\n{repo.git.status()} \n\n\n--- git diff ---\n{repo.git.diff(t)}" content = f"--- git status ---\n{repo.git.status()} \n\n\n--- git diff ---\n{repo.git.diff(t)}"
f.write(content) f.write(content)
# add the file path to the list of files to be uploaded # add the file path to the list of files to be uploaded