From 64ed0eca2de080c44bff948e7c10f726b77be948 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Thu, 29 Apr 2021 19:18:41 +0300 Subject: Do not accidentally format files when only checking if they are formatted. --- mesonbuild/scripts/clangformat.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mesonbuild/scripts/clangformat.py b/mesonbuild/scripts/clangformat.py index ceb36ac..9c09609 100644 --- a/mesonbuild/scripts/clangformat.py +++ b/mesonbuild/scripts/clangformat.py @@ -37,7 +37,10 @@ def parse_pattern_file(fname: Path) -> T.List[str]: def run_clang_format(exelist: T.List[str], fname: Path, check: bool) -> subprocess.CompletedProcess: before = fname.stat().st_mtime - ret = subprocess.run(exelist + ['-style=file', '-i', str(fname)]) + args = ['-style=file', str(fname)] + if check: + args = ['-i'] + args + ret = subprocess.run(exelist + args) after = fname.stat().st_mtime if before != after: print('File reformatted: ', fname) -- cgit v1.1