Skip to content

Commit 242847f

Browse files
committed
feat: Improve logging for unchanged files
1 parent b6257e0 commit 242847f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ feefifofum <directory1> <directory2> # Format all feature files in multiple dir
4646
```
4747

4848
### Output
49-
In its default setting, `feefifofum` will only log the total number of files formatted to the console.
50-
The `--verbose` or `-v` flag can be passed to log information on which files have been formatted and overall progress.
49+
In its default setting, `feefifofum` will only log the total number of formatted and unchanged files to the console.
50+
Files marked as 'unchanged' already meet the required formatting standard and therefore no changes are written to these files.
51+
52+
The `--verbose` or `-v` flag can be passed to log realtime information on which files have been formatted (or are unchanged), and overall progress.
5153
```shell
5254
feefifofum <file1> <file2> <file3> --verbose
5355
```

feefifofum/main.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,25 @@ def main() -> None: # pragma: no cover
2121
logging.warning('No feature file(s) found in specified path(s)')
2222
return
2323

24+
changed_count, unchanged_count = 0, 0
2425
for index, file_path in enumerate(file_paths, 1):
2526
file_lines = read_file_lines(file_path)
2627
formatted_file_lines = format_feature_file(file_lines)
28+
29+
if file_lines == formatted_file_lines:
30+
logging.debug(f'({index}/{file_count}) | unchanged | {file_path}')
31+
unchanged_count += 1
32+
continue
33+
2734
write_file_lines(formatted_file_lines, file_path)
28-
logging.debug(f'Formatted: {file_path} ({index}/{file_count})')
35+
logging.debug(f'({index}/{file_count}) | formatted | {file_path}')
36+
changed_count += 1
37+
38+
if changed_count:
39+
logging.info(f'{changed_count} file(s) formatted')
2940

30-
logging.info(f'Formatted {file_count} file(s)')
41+
if unchanged_count:
42+
logging.info(f'{unchanged_count} file(s) unchanged')
3143

3244

3345
if __name__ == '__main__': # pragma: no cover

0 commit comments

Comments
 (0)