Skip to content
Snippets Groups Projects
Commit 5d3d097a authored by Corné Lukken's avatar Corné Lukken
Browse files

L2SS-287: Add separator between branch and commit in version

parent d3849348
No related branches found
No related tags found
1 merge request!146L2SS-287: implement python packaging
...@@ -44,7 +44,7 @@ def get_version(repo: git.Repo = None) -> str: ...@@ -44,7 +44,7 @@ def get_version(repo: git.Repo = None) -> str:
to request the version early enough. to request the version early enough.
The version string is of the following pattern: 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 For releases only ${MAJOR}.${MINOR}.${PATCH} should be set. Versioning is
achieved by tagging commits using the `v${MAJOR}.${MINOR}.${PATCH}` pattern. achieved by tagging commits using the `v${MAJOR}.${MINOR}.${PATCH}` pattern.
...@@ -88,7 +88,7 @@ def get_version(repo: git.Repo = None) -> str: ...@@ -88,7 +88,7 @@ def get_version(repo: git.Repo = None) -> str:
else: else:
# HEAD of a branch # HEAD of a branch
branch = repo.active_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 "") return "{}{}".format(commit_str, ".dirty" if repo.is_dirty() else "")
......
...@@ -15,10 +15,10 @@ from tangostationcontrol.common import lofar_version ...@@ -15,10 +15,10 @@ from tangostationcontrol.common import lofar_version
from tangostationcontrol.test import base from tangostationcontrol.test import base
class TestLofarGit(base.TestCase): class TestLofarVersion(base.TestCase):
def setUp(self): def setUp(self):
super(TestLofarGit, self).setUp() super(TestLofarVersion, self).setUp()
# Clear the cache as this function of lofar_version uses LRU decorator # 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 # This is a good demonstration of how unit tests in Python can have
...@@ -43,7 +43,7 @@ class TestLofarGit(base.TestCase): ...@@ -43,7 +43,7 @@ class TestLofarGit(base.TestCase):
is_dirty=m_is_dirty, head=m_head) is_dirty=m_is_dirty, head=m_head)
# No need for special string equal in Python # 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): def test_get_version_tag(self):
"""Test if get_version determines production_ready for tagged commit""" """Test if get_version determines production_ready for tagged commit"""
...@@ -92,7 +92,7 @@ class TestLofarGit(base.TestCase): ...@@ -92,7 +92,7 @@ class TestLofarGit(base.TestCase):
is_dirty=m_is_dirty, head=m_head) is_dirty=m_is_dirty, head=m_head)
# No need for special string equal in Python # 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): def test_catch_repo_error(self):
"""Test if invalid git directories will raise error""" """Test if invalid git directories will raise error"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment