Skip to content

Commit

Permalink
[Github] Print diff in code format helper (#72742)
Browse files Browse the repository at this point in the history
Currently, when the code format action fails, it leaves no log of the
diff in the output within the action itself. This has caused confusion
for some users of the action, especially when the comment becomes buried
in a 100+ comment review and someone isn't super familiar with the inner
workings of the CI. This patch prints the diff produced by the code
formatter to stdout so that it is viewable by clicking on the failed
action. This should have very little cost and make things slightly less
confusing for those that run into this situation.
  • Loading branch information
boomanaiden154 committed Nov 18, 2023
1 parent f8df86e commit 56d0e8c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llvm/utils/git/code-format-helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def format_run(
if proc.returncode != 0:
# formatting needed, or the command otherwise failed
print(f"error: {self.name} exited with code {proc.returncode}")
# Print the diff in the log so that it is viewable there
print(proc.stdout.decode("utf-8"))
return proc.stdout.decode("utf-8")
else:
sys.stdout.write(proc.stdout.decode("utf-8"))
Expand Down Expand Up @@ -200,6 +202,8 @@ def format_run(
if proc.returncode != 0:
# formatting needed, or the command otherwise failed
print(f"error: {self.name} exited with code {proc.returncode}")
# Print the diff in the log so that it is viewable there
print(proc.stdout.decode("utf-8"))
return proc.stdout.decode("utf-8")
else:
sys.stdout.write(proc.stdout.decode("utf-8"))
Expand Down

0 comments on commit 56d0e8c

Please sign in to comment.