From 48488f16839263dd8a78916084de0923dda42672 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Wed, 17 Feb 2021 14:04:04 +0100 Subject: [PATCH] tools: Use git describe --match for filtering out internal names --- make/project.mk | 2 +- tools/ci/test_build_system_cmake.sh | 16 ++++++++++++++++ tools/cmake/build.cmake | 2 +- tools/idf_py_actions/tools.py | 3 ++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/make/project.mk b/make/project.mk index e7fc7257aa..f3f1a8220b 100644 --- a/make/project.mk +++ b/make/project.mk @@ -338,7 +338,7 @@ endif # If we have `version.txt` then prefer that for extracting IDF version ifeq ("$(wildcard ${IDF_PATH}/version.txt)","") -IDF_VER_T := $(shell cd ${IDF_PATH} && git describe --always --dirty) +IDF_VER_T := $(shell cd ${IDF_PATH} && git describe --always --dirty --match v*.*) else IDF_VER_T := $(shell cat ${IDF_PATH}/version.txt) endif diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index d0d24dd6bb..8c9032a15d 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -146,6 +146,22 @@ function run_tests() idf.py reconfigure || failure "Failed to use IDF_VERSION_MAJOR in component CMakeLists.txt" git checkout -- main/CMakeLists.txt + print_status "Project is in ESP-IDF which has a custom tag" + pushd ${IDF_PATH}/examples/get-started/hello_world + git config user.email "noone@espressif.com" + git config user.name "No One" + git tag mytag -a -m "mytag" + idf.py reconfigure &> log.log || failure "Failed to build" + str="App \"hello-world\" version: mytag" + grep "${str}" log.log || { cat log.log ; failure "Project version should be the custom tag"; } + idf_version=$(idf.py --version) + if [[ "$idf_version" == *"mytag"* ]]; then + failure "IDF version $idf_version should not contain mytag" + fi + git tag -d mytag + rm -rf sdkconfig build + popd + print_status "Moving BUILD_DIR_BASE out of tree" clean_build_dir OUTOFTREE_BUILD=${TESTDIR}/alt_build diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index 54fd6520fb..e9e1c1ed3c 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -64,7 +64,7 @@ endfunction() # function(__build_get_idf_git_revision) idf_build_get_property(idf_path IDF_PATH) - git_describe(idf_ver_git "${idf_path}") + git_describe(idf_ver_git "${idf_path}" "--match v*.*") if(EXISTS "${idf_path}/version.txt") file(STRINGS "${idf_path}/version.txt" idf_ver_t) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${idf_path}/version.txt") diff --git a/tools/idf_py_actions/tools.py b/tools/idf_py_actions/tools.py index 6ba0702989..78f74975d7 100644 --- a/tools/idf_py_actions/tools.py +++ b/tools/idf_py_actions/tools.py @@ -55,7 +55,8 @@ def idf_version(): version = subprocess.check_output([ 'git', '--git-dir=%s' % os.path.join(os.environ['IDF_PATH'], '.git'), - '--work-tree=%s' % os.environ['IDF_PATH'], 'describe', '--tags', '--dirty' + '--work-tree=%s' % os.environ['IDF_PATH'], + 'describe', '--tags', '--dirty', '--match', 'v*.*', ]).decode('utf-8', 'ignore').strip() except (subprocess.CalledProcessError, UnicodeError): # if failed, then try to parse cmake.version file