From c843e64cf538d9869b18d647b46bbb21190f64d0 Mon Sep 17 00:00:00 2001 From: Jiabin Yang Date: Mon, 13 May 2019 15:17:03 +0800 Subject: [PATCH] Revert "rename the default version from '0.0.0' to 'latest' (#17304)" (#17356) This reverts commit f456c8beb809b447527d378ef6b29a431b1b09cc. --- cmake/version.cmake | 16 +++++++--------- .../paddle/fluid/tests/unittests/test_version.py | 10 +++++++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cmake/version.cmake b/cmake/version.cmake index f7b065b582c..dd57d4ab996 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -3,8 +3,6 @@ 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]+[0-9a-f]+[0-9a-f]+[0-9a-f]+[0-9a-f]+") -set(LATEST_PADDLE_VERSION "latest") - while ("${PADDLE_VERSION}" STREQUAL "") # Check current branch name execute_process( @@ -25,8 +23,8 @@ while ("${PADDLE_VERSION}" STREQUAL "") if (${GIT_BRANCH_NAME} MATCHES "release/${TAG_VERSION_REGEX}") # Check the tag is a correct version if (${GIT_TAG_NAME} MATCHES "${COMMIT_VERSION_REGEX}") - # if no tag was found, set PADDLE_VERSION to "latest" - set(PADDLE_VERSION "${LATEST_PADDLE_VERSION}") + # if no tag was found, set PADDLE_VERSION to 0.0.0 to represent latest + set(PADDLE_VERSION "0.0.0") 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. @@ -44,19 +42,19 @@ while ("${PADDLE_VERSION}" STREQUAL "") if (${GIT_EXACT_TAG_NAME} MATCHES "v${TAG_VERSION_REGEX}") string(REPLACE "v" "" PADDLE_VERSION ${GIT_EXACT_TAG_NAME}) else() - set(PADDLE_VERSION "${LATEST_PADDLE_VERSION}") + set(PADDLE_VERSION "0.0.0") endif() else() - # otherwise, we always set PADDLE_VERSION to "latest" - set(PADDLE_VERSION "${LATEST_PADDLE_VERSION}") + # otherwise, we always set PADDLE_VERSION to 0.0.0 to represent latest + set(PADDLE_VERSION "0.0.0") endif() endif() else() - set(PADDLE_VERSION "${LATEST_PADDLE_VERSION}") + set(PADDLE_VERSION "0.0.0") message(WARNING "Cannot add paddle version from git tag") endif() else() - set(PADDLE_VERSION "${LATEST_PADDLE_VERSION}") + set(PADDLE_VERSION "0.0.0") message(WARNING "Cannot add paddle version for wrong git branch result") endif() endwhile() diff --git a/python/paddle/fluid/tests/unittests/test_version.py b/python/paddle/fluid/tests/unittests/test_version.py index a3927ef11d3..42a0e5c802c 100644 --- a/python/paddle/fluid/tests/unittests/test_version.py +++ b/python/paddle/fluid/tests/unittests/test_version.py @@ -30,14 +30,18 @@ class VersionTest(unittest.TestCase): self._commit_regex = "[0-9a-f]{5,49}" def test_check_output(self): + # check commit format + self.assertTrue(re.match(self._commit_regex, fluid_version.commit)) self.assertTrue(isinstance(fluid_version.istaged, bool)) # check version format if fluid_version.istaged: - self.assertEqual(fluid_version.full_version, "latest") + self.assertEqual(fluid_version.major, 0) + self.assertEqual(fluid_version.minor, 0) + self.assertEqual(fluid_version.patch, "0") + self.assertEqual(fluid_version.rc, 0) + self.assertEqual(fluid_version.full_version, "0.0.0") else: - # check commit format - self.assertTrue(re.match(self._commit_regex, fluid_version.commit)) self.assertTrue(re.match(self._major_regex, fluid_version.major)) self.assertTrue(re.match(self._minor_regex, fluid_version.minor)) self.assertTrue(re.match(self._patch_regex, fluid_version.patch)) -- GitLab