Skip to content

Commit 56d0e8c

Browse files
[Github] Print diff in code format helper (llvm#72742)
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.
1 parent f8df86e commit 56d0e8c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

llvm/utils/git/code-format-helper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ def format_run(
156156
if proc.returncode != 0:
157157
# formatting needed, or the command otherwise failed
158158
print(f"error: {self.name} exited with code {proc.returncode}")
159+
# Print the diff in the log so that it is viewable there
160+
print(proc.stdout.decode("utf-8"))
159161
return proc.stdout.decode("utf-8")
160162
else:
161163
sys.stdout.write(proc.stdout.decode("utf-8"))
@@ -200,6 +202,8 @@ def format_run(
200202
if proc.returncode != 0:
201203
# formatting needed, or the command otherwise failed
202204
print(f"error: {self.name} exited with code {proc.returncode}")
205+
# Print the diff in the log so that it is viewable there
206+
print(proc.stdout.decode("utf-8"))
203207
return proc.stdout.decode("utf-8")
204208
else:
205209
sys.stdout.write(proc.stdout.decode("utf-8"))

0 commit comments

Comments
 (0)