aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-04-29 19:18:41 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2021-04-29 19:18:41 +0300
commit64ed0eca2de080c44bff948e7c10f726b77be948 (patch)
tree5e73a1d423b8e16d3056a0537fa665cddb83b6d5
parentcdc6c866ca087ba738f0a5d01cc0fc6ddc066935 (diff)
downloadmeson-clangformatcheck.zip
meson-clangformatcheck.tar.gz
meson-clangformatcheck.tar.bz2
Do not accidentally format files when only checking if they are formatted.clangformatcheck
-rw-r--r--mesonbuild/scripts/clangformat.py5
1 files changed, 4 insertions, 1 deletions
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)