From 1af7d5a2e80f1abe12fcdbbc81262ceb287e051b Mon Sep 17 00:00:00 2001 From: minqiyang Date: Fri, 6 Jul 2018 15:03:39 +0800 Subject: [PATCH] Change the incorrect version result from UNKNOWN to 0 Replace {} to + in cmake regex match --- cmake/version.cmake | 4 ++-- python/setup.py.in | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/version.cmake b/cmake/version.cmake index 96f2eff6cbf..4a86ad2e09f 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -2,7 +2,7 @@ set(PADDLE_VERSION $ENV{PADDLE_VERSION}) set(tmp_version "HEAD") set(TAG_VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+(\\.(a|b|rc)\\.[0-9]+)?") -set(COMMIT_VERSION_REGEX "[0-9a-f]{5,40}") +set(COMMIT_VERSION_REGEX "[0-9a-f]+") while ("${PADDLE_VERSION}" STREQUAL "") execute_process( COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 --always ${tmp_version} @@ -15,7 +15,7 @@ while ("${PADDLE_VERSION}" STREQUAL "") if (${GIT_TAG_NAME} MATCHES "${COMMIT_VERSION_REGEX}") # if no tag was found, set PADDLE_VERSION to latest set(PADDLE_VERSION "latest") - elseif (${GIT_TAG_NAME} MATCHES "v${VERSION_REGEX}") + elseif (${GIT_TAG_NAME} MATCHES "v${TAG_VERSION_REGEX}") string(REPLACE "v" "" PADDLE_VERSION ${GIT_TAG_NAME}) else() # otherwise, get the previous git tag name. set(tmp_version "${GIT_TAG_NAME}~1") diff --git a/python/setup.py.in b/python/setup.py.in index 8ea828ce65d..6e21512b864 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -29,7 +29,7 @@ def _get_version_detail(idx): if len(version_details) == 3: return version_details[idx] - return 'UNKNOWN' + return 0 def get_major(): return _get_version_detail(0) -- GitLab