Skip to content

Commit 6612b01

Browse files
committed
Fixes to log output (remove "Formatter" lines, fix order)
* Prefix "clang-format" to the Excluding lines rather than print "Formatter darker (Python code formatter):" and "Formatter clang-format (C/C++ code formatter):" Those formatter lines were being printed even when there were no C++/Python files to format. * Capture stderr and then print it out, rather than let the subprocess directly write it out. This ensures that output appears in the right order when the script's output is buffered.
1 parent dcb50e4 commit 6612b01

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def update_pr(
8686
pr.as_issue().create_comment(comment_text)
8787

8888
def run(self, changed_files: list[str], args: argparse.Namespace) -> bool:
89-
print(f"Formatter {self.name} ({self.friendly_name}):")
9089
diff = self.format_run(changed_files, args)
9190
if diff is None:
9291
comment_text = f"""
@@ -123,7 +122,7 @@ def libcxx_excluded_files(self) -> list[str]:
123122

124123
def should_be_excluded(self, path: str) -> bool:
125124
if path in self.libcxx_excluded_files:
126-
print(f"Excluding file {path}")
125+
print(f"{self.name}: Excluding file {path}")
127126
return True
128127
return False
129128

@@ -151,7 +150,8 @@ def format_run(
151150
] + cpp_files
152151
print(f"Running: {' '.join(cf_cmd)}")
153152
self.cf_cmd = cf_cmd
154-
proc = subprocess.run(cf_cmd, stdout=subprocess.PIPE)
153+
proc = subprocess.run(cf_cmd, capture_output=True)
154+
sys.stdout.write(proc.stderr.decode("utf-8"))
155155

156156
if proc.returncode != 0:
157157
# formatting needed, or the command otherwise failed
@@ -194,7 +194,8 @@ def format_run(
194194
] + py_files
195195
print(f"Running: {' '.join(darker_cmd)}")
196196
self.darker_cmd = darker_cmd
197-
proc = subprocess.run(darker_cmd, stdout=subprocess.PIPE)
197+
proc = subprocess.run(darker_cmd, capture_output=True)
198+
sys.stdout.write(proc.stderr.decode("utf-8"))
198199

199200
if proc.returncode != 0:
200201
# formatting needed, or the command otherwise failed

0 commit comments

Comments
 (0)