Merge pull request #5137 from jepler/codeformat-error-checking

Codeformat version checking
This commit is contained in:
Scott Shawcroft 2021-08-13 14:53:51 -07:00 committed by GitHub
commit af823cce07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -119,6 +119,15 @@ C_EXTS = (
)
PY_EXTS = (".py",)
def check_uncrustify_version():
version = subprocess.check_output(
["uncrustify", "--version"], encoding="utf-8", errors="replace"
)
if version < "Uncrustify-0.71":
raise SystemExit(f"codeformat.py requires Uncrustify 0.71 or newer, got {version}")
# Transform a filename argument relative to the current directory into one
# relative to the TOP directory, which is what we need when checking against
# path_rx.
@ -218,6 +227,7 @@ def main():
# Format C files with uncrustify.
if format_c:
check_uncrustify_version()
command = ["uncrustify", "-c", UNCRUSTIFY_CFG, "-lC", "--no-backup"]
if not args.v:
command.append("-q")