tools: Use git describe --match for filtering out internal names

This commit is contained in:
Roland Dobai 2021-02-17 14:04:04 +01:00 committed by bot
parent ced15b0dc0
commit 48488f1683
4 changed files with 20 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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