From 1091defe43eed735f7b4cf4ad576047d9aaba8e9 Mon Sep 17 00:00:00 2001 From: Jakub Kocka Date: Wed, 5 Jun 2024 15:28:20 +0200 Subject: [PATCH] fix(tools): Avoid crashing when Git is used to acquire IDF version Closes https://github.com/espressif/esp-idf/issues/13345 --- tools/idf_py_actions/tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/idf_py_actions/tools.py b/tools/idf_py_actions/tools.py index 85d9c8831a..ad666c7b45 100644 --- a/tools/idf_py_actions/tools.py +++ b/tools/idf_py_actions/tools.py @@ -4,7 +4,6 @@ import os import re import subprocess import sys -from io import open import click @@ -22,6 +21,7 @@ def executable_exists(args): def _idf_version_from_cmake(): + """Acquires version of ESP-IDF from version.cmake""" version_path = os.path.join(os.environ['IDF_PATH'], 'tools/cmake/version.cmake') regex = re.compile(r'^\s*set\s*\(\s*IDF_VERSION_([A-Z]{5})\s+(\d+)') ver = {} @@ -55,7 +55,7 @@ def idf_version(): '--work-tree=%s' % os.environ['IDF_PATH'], 'describe', '--tags', '--dirty', '--match', 'v*.*', ]).decode('utf-8', 'ignore').strip() - except (subprocess.CalledProcessError, UnicodeError): + except Exception: # if failed, then try to parse cmake.version file sys.stderr.write('WARNING: Git version unavailable, reading from source\n') version = _idf_version_from_cmake()