summaryrefslogtreecommitdiff
path: root/format.py
diff options
context:
space:
mode:
authorDragorn421 <Dragorn421@users.noreply.github.com>2024-01-31 04:25:24 +0100
committerGitHub <noreply@github.com>2024-01-30 22:25:24 -0500
commit44408ce219a0a84f4b2491c20eb4bc80b1959a3d (patch)
tree1fe6309c78e2b1c5479d84b0acab597e2452a696 /format.py
parent87a886df5ba8c8ddd70bccc74197aaaefaeb4bd8 (diff)
Only check formatting on modified files (#1673)
* only check formatting on modified files (attempt 1) * foreshadow maximum command string length being an issue and pass files list using a file * rm temp file list otherwise it shows in git status and counts as a "formatting diff"... * cheeky z_play modif * format
Diffstat (limited to 'format.py')
-rwxr-xr-xformat.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/format.py b/format.py
index 520a2d807..023ddfd7a 100755
--- a/format.py
+++ b/format.py
@@ -9,6 +9,7 @@ import shutil
import subprocess
import sys
import tempfile
+from pathlib import Path
from functools import partial
from typing import List
@@ -150,6 +151,15 @@ def main():
action="store_true",
help="Print the paths to the clang-* binaries used",
)
+ parser.add_argument(
+ "--files-list",
+ dest="files_list",
+ help="A file listing the files to format",
+ )
+ parser.add_argument(
+ "--verbose",
+ action="store_true",
+ )
parser.add_argument("files", metavar="file", nargs="*")
parser.add_argument(
"-j",
@@ -175,10 +185,18 @@ def main():
f"Error: neither clang-apply-replacements nor clang-apply-replacements-{CLANG_VER} found (required to use -j)"
)
- if args.files:
- files = args.files
+ if args.files or args.files_list:
+ files = []
+ files.extend(args.files)
+ if args.files_list:
+ files.extend(Path(args.files_list).read_text().split())
+ files = list(files)
extra_files = []
+ if args.verbose:
+ print("Formatting specific files:", len(files), files)
else:
+ if args.verbose:
+ print("Formatting all files")
files = glob.glob("src/**/*.c", recursive=True)
extra_files = glob.glob("assets/**/*.xml", recursive=True)