From 736cd6a0663ce43d70f0e93d6b7843953b29456b Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Thu, 29 Aug 2024 02:33:41 +0100 Subject: [PATCH] check-style: Fix clang-format version check --- utils/check-style-clang-format.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/utils/check-style-clang-format.py b/utils/check-style-clang-format.py index 602effe22..129001cc1 100755 --- a/utils/check-style-clang-format.py +++ b/utils/check-style-clang-format.py @@ -261,16 +261,20 @@ def find_clang_format_path() -> str: check=True, ) - version = process.stdout.strip().split(" ")[-1] - major_version = int(version.split(".")[0]) + clang_format_version = process.stdout.strip() + version_regex = re.findall(r"\b(\d+)(\.\d+){0,2}\b", clang_format_version) - if major_version in CLANG_FORMAT_VERSIONS: - return clang_format_path + if version_regex: + major_version = int(version_regex[0][0]) + + if major_version in CLANG_FORMAT_VERSIONS: + return clang_format_path # No supported version of clang-format found raise RuntimeError( f"Could not find any supported version of clang-format installed on this system. " - f"List of supported versions: {CLANG_FORMAT_VERSIONS}." + f"List of supported versions: {CLANG_FORMAT_VERSIONS}. " + + (f"Found clang-format {major_version}." if version_regex else "") )