[llvm] [Github] Print diff in code format helper (PR #72742)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 17 21:55:50 PST 2023


https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/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.

>From 35baa6cfdcd22ce431d07cbb1f5845dede13a071 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Fri, 17 Nov 2023 21:46:55 -0800
Subject: [PATCH] [Github] Print diff in code format helper

---
 llvm/utils/git/code-format-helper.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py
index c45bb4d935d478a..32745768dc74c4d 100644
--- a/llvm/utils/git/code-format-helper.py
+++ b/llvm/utils/git/code-format-helper.py
@@ -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"))
@@ -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"))



More information about the llvm-commits mailing list