Skip to content

Commit 0171bc9

Browse files
author
Thierry Delafontaine
committed
feat: print the name of formatted files and a summary at the end
1 parent d70c60a commit 0171bc9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pre_commit_hooks/emacs_vhdl_formatter.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def main() -> int:
3737
cmd += Config.base_args
3838
cmd.append(lisp_code)
3939

40-
return_code = 0
40+
num_formatted = 0
41+
num_checked = 0
4142
for filename in args.filenames:
4243
with open(filename, "r+") as f:
4344
with subprocess.Popen(
@@ -56,8 +57,10 @@ def main() -> int:
5657
f.truncate()
5758
f.write(formatted_code)
5859
logging.info(f"{filename} successfully formatted")
60+
num_checked += 1
5961
if file_content != formatted_code:
60-
return_code = 1
62+
num_formatted += 1
63+
print(f"reformatted {filename}")
6164
else:
6265
logging.error(f"{errs}")
6366

@@ -66,7 +69,11 @@ def main() -> int:
6669
_, errs = proc.communicate()
6770
logging.error(f"Subprocess timed out: {errs}")
6871
return proc.returncode
69-
return return_code
72+
if num_formatted > 0:
73+
print(f"{num_formatted} file(s) formatted, {num_checked} files checked")
74+
return 1
75+
else:
76+
return 0
7077

7178

7279
def construct_lisp_code(tab_width: int, custom_eval: str) -> str:

0 commit comments

Comments
 (0)