diff options
Diffstat (limited to 'lib/python/qmk/cli/cformat.py')
| -rw-r--r-- | lib/python/qmk/cli/cformat.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/python/qmk/cli/cformat.py b/lib/python/qmk/cli/cformat.py index 0cd8b6192..600161c5c 100644 --- a/lib/python/qmk/cli/cformat.py +++ b/lib/python/qmk/cli/cformat.py | |||
| @@ -4,7 +4,9 @@ import subprocess | |||
| 4 | from shutil import which | 4 | from shutil import which |
| 5 | 5 | ||
| 6 | from milc import cli | 6 | from milc import cli |
| 7 | import qmk.path | 7 | |
| 8 | from qmk.path import normpath | ||
| 9 | from qmk.c_parse import c_source_files | ||
| 8 | 10 | ||
| 9 | 11 | ||
| 10 | def cformat_run(files, all_files): | 12 | def cformat_run(files, all_files): |
| @@ -45,10 +47,10 @@ def cformat(cli): | |||
| 45 | ignores = ['tmk_core/protocol/usb_hid', 'quantum/template'] | 47 | ignores = ['tmk_core/protocol/usb_hid', 'quantum/template'] |
| 46 | # Find the list of files to format | 48 | # Find the list of files to format |
| 47 | if cli.args.files: | 49 | if cli.args.files: |
| 48 | files.extend(qmk.path.normpath(file) for file in cli.args.files) | 50 | files.extend(normpath(file) for file in cli.args.files) |
| 49 | # If -a is specified | 51 | # If -a is specified |
| 50 | elif cli.args.all_files: | 52 | elif cli.args.all_files: |
| 51 | all_files = qmk.path.c_source_files(core_dirs) | 53 | all_files = c_source_files(core_dirs) |
| 52 | # The following statement checks each file to see if the file path is in the ignored directories. | 54 | # The following statement checks each file to see if the file path is in the ignored directories. |
| 53 | files.extend(file for file in all_files if not any(i in str(file) for i in ignores)) | 55 | files.extend(file for file in all_files if not any(i in str(file) for i in ignores)) |
| 54 | # No files specified & no -a flag | 56 | # No files specified & no -a flag |
| @@ -56,7 +58,7 @@ def cformat(cli): | |||
| 56 | base_args = ['git', 'diff', '--name-only', cli.args.base_branch] | 58 | base_args = ['git', 'diff', '--name-only', cli.args.base_branch] |
| 57 | out = subprocess.run(base_args + core_dirs, check=True, stdout=subprocess.PIPE) | 59 | out = subprocess.run(base_args + core_dirs, check=True, stdout=subprocess.PIPE) |
| 58 | changed_files = filter(None, out.stdout.decode('UTF-8').split('\n')) | 60 | changed_files = filter(None, out.stdout.decode('UTF-8').split('\n')) |
| 59 | filtered_files = [qmk.path.normpath(file) for file in changed_files if not any(i in file for i in ignores)] | 61 | filtered_files = [normpath(file) for file in changed_files if not any(i in file for i in ignores)] |
| 60 | files.extend(file for file in filtered_files if file.exists() and file.suffix in ['.c', '.h', '.cpp']) | 62 | files.extend(file for file in filtered_files if file.exists() and file.suffix in ['.c', '.h', '.cpp']) |
| 61 | 63 | ||
| 62 | # Run clang-format on the files we've found | 64 | # Run clang-format on the files we've found |
