From 5d3d097aa29738ad6edebf832a4e58e6eadcbe84 Mon Sep 17 00:00:00 2001 From: lukken <lukken@astron.nl> Date: Tue, 26 Oct 2021 08:32:44 +0000 Subject: [PATCH] L2SS-287: Add separator between branch and commit in version --- .../tangostationcontrol/common/lofar_version.py | 4 ++-- .../common/{test_lofar_git.py => test_lofar_version.py} | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) rename tangostationcontrol/tangostationcontrol/test/common/{test_lofar_git.py => test_lofar_version.py} (93%) diff --git a/tangostationcontrol/tangostationcontrol/common/lofar_version.py b/tangostationcontrol/tangostationcontrol/common/lofar_version.py index 92fe0f5fa..0d38c9b95 100644 --- a/tangostationcontrol/tangostationcontrol/common/lofar_version.py +++ b/tangostationcontrol/tangostationcontrol/common/lofar_version.py @@ -44,7 +44,7 @@ def get_version(repo: git.Repo = None) -> str: to request the version early enough. The version string is of the following pattern: - - ${MAJOR}.${MINOR}.${PATCH}[.${BRANCH}${COMMIT}][.dirty] + - ${MAJOR}.${MINOR}.${PATCH}[.${BRANCH}$.{COMMIT}][.dirty] For releases only ${MAJOR}.${MINOR}.${PATCH} should be set. Versioning is achieved by tagging commits using the `v${MAJOR}.${MINOR}.${PATCH}` pattern. @@ -88,7 +88,7 @@ def get_version(repo: git.Repo = None) -> str: else: # HEAD of a branch branch = repo.active_branch - commit_str = "{}.{}{}".format(closest_tag.name[1:], branch, commit) + commit_str = "{}.{}.{}".format(closest_tag.name[1:], branch, commit) return "{}{}".format(commit_str, ".dirty" if repo.is_dirty() else "") diff --git a/tangostationcontrol/tangostationcontrol/test/common/test_lofar_git.py b/tangostationcontrol/tangostationcontrol/test/common/test_lofar_version.py similarity index 93% rename from tangostationcontrol/tangostationcontrol/test/common/test_lofar_git.py rename to tangostationcontrol/tangostationcontrol/test/common/test_lofar_version.py index ff51bafbf..89ac894d9 100644 --- a/tangostationcontrol/tangostationcontrol/test/common/test_lofar_git.py +++ b/tangostationcontrol/tangostationcontrol/test/common/test_lofar_version.py @@ -15,10 +15,10 @@ from tangostationcontrol.common import lofar_version from tangostationcontrol.test import base -class TestLofarGit(base.TestCase): +class TestLofarVersion(base.TestCase): def setUp(self): - super(TestLofarGit, self).setUp() + super(TestLofarVersion, self).setUp() # Clear the cache as this function of lofar_version uses LRU decorator # This is a good demonstration of how unit tests in Python can have @@ -43,7 +43,7 @@ class TestLofarGit(base.TestCase): is_dirty=m_is_dirty, head=m_head) # No need for special string equal in Python - self.assertEqual("0.0.0.main123456", lofar_version.get_version()) + self.assertEqual("0.0.0.main.123456", lofar_version.get_version()) def test_get_version_tag(self): """Test if get_version determines production_ready for tagged commit""" @@ -92,7 +92,7 @@ class TestLofarGit(base.TestCase): is_dirty=m_is_dirty, head=m_head) # No need for special string equal in Python - self.assertEqual("0.0.0.main123456.dirty", lofar_version.get_version()) + self.assertEqual("0.0.0.main.123456.dirty", lofar_version.get_version()) def test_catch_repo_error(self): """Test if invalid git directories will raise error""" -- GitLab