Skip to content

Commit

Permalink
Merge pull request #79 from usefulness/updates
Browse files Browse the repository at this point in the history
Fix Windows encoding
  • Loading branch information
mateuszkwiecinski authored Mar 7, 2024
2 parents 328a0cb + 2e46147 commit 45442de
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import uuid
import zipfile
import stat
import sys
from itertools import zip_longest


Expand Down Expand Up @@ -144,6 +143,9 @@ def sizeof_fmt(num, suffix='B', sign=False):
exec_call.extend(["--old-mapping", os.getenv("INPUT_OLD_MAPPING_FILE")])
if os.getenv("INPUT_NEW_MAPPING_FILE").strip():
exec_call.extend(["--new-mapping", os.getenv("INPUT_NEW_MAPPING_FILE")])
exec_call.append("--text")
output_file_name = "diffuse-output.txt"
exec_call.append(output_file_name)

oldSize = os.stat(oldFile).st_size
oldSizeText = sizeof_fmt(oldSize)
Expand All @@ -158,16 +160,20 @@ def sizeof_fmt(num, suffix='B', sign=False):
print(diffComment1)
print(" ".join(exec_call))

os.system(f"echo \"size-old-bytes={oldSize}\" >> $GITHUB_OUTPUT")
os.system(f"echo \"size-old-text={oldSizeText}\" >> $GITHUB_OUTPUT")
os.system(f"echo \"size-new-bytes={newSize}\" >> $GITHUB_OUTPUT")
os.system(f"echo \"size-new-text={newSizeText}\" >> $GITHUB_OUTPUT")
os.system(f"echo \"size-diff-comment_style_1={diffComment1}\" >> $GITHUB_OUTPUT")
github_output("size-old-bytes", oldSize)
github_output("size-old-text", oldSizeText)
github_output("size-new-bytes", newSize)
github_output("size-new-text", newSizeText)
github_output("size-diff-comment_style_1", diffComment1)

process = subprocess.Popen(exec_call, stdout=subprocess.PIPE)
out, _ = process.communicate()

diff = out.decode(encoding=sys.stdout.encoding).strip()
process = subprocess.run(exec_call)
if process.returncode != 0:
raise Exception("Error while executing diffuse")

with open(output_file_name, mode="r", encoding="utf-8") as output:
outputPath = os.path.realpath(output.name)
diff = output.read()

if process.returncode != 0:
raise Exception("Error while executing diffuse")
Expand All @@ -180,6 +186,7 @@ def sizeof_fmt(num, suffix='B', sign=False):

if is_debug():
print(f"Found {len(sections)} sections")
print(f"Full output stored in: {outputPath}")

github_comment = ""
github_comment_all_collapsed = ""
Expand All @@ -206,13 +213,6 @@ def sizeof_fmt(num, suffix='B', sign=False):
github_comment_no_dex += section(title.strip(), value)
github_comment_no_dex_all_collapsed += section(title.strip(), value)

output = open("diffuse-output.txt", "w")
output.write(diff)
output.close()
outputPath = os.path.realpath(output.name)
if is_debug():
print(f"Full output stored in: {outputPath}")

github_output("diff-file", outputPath)
github_output("diff-raw", diff[0:github_output_limit])
github_output("diff-gh-comment", github_comment)
Expand Down

0 comments on commit 45442de

Please sign in to comment.