From 8181c5be48c736dadb1d2733306ab8edb8a2d05e Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Thu, 9 Nov 2017 16:37:57 +0100 Subject: [PATCH] Turn COMPOSE_ID version generator into DATE_RESPIN Signed-off-by: Patrick Uiterwijk --- doc/configuration.rst | 24 +++++++++++++----------- pungi/util.py | 7 ++++--- tests/test_util.py | 7 ++++--- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/doc/configuration.rst b/doc/configuration.rst index fd5b67b1..077457c2 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -950,17 +950,17 @@ Version and release values for certain artifacts can be generated automatically based on release version, compose label, date, type and respin. This can be used to shorten the config and keep it the same for multiple uses. -+----------------------------+-------------------+--------------+------------------+ -| Compose ID | Label | Version | Release | -+============================+===================+==============+==================+ -| ``F-Rawhide-20170406.n.0`` | ``-`` | ``Rawhide`` | ``20170406.n.0`` | -+----------------------------+-------------------+--------------+------------------+ -| ``F-26-20170329.1`` | ``Alpha-1.6`` | ``26_Alpha`` | ``1.6`` | -+----------------------------+-------------------+--------------+------------------+ -| ``F-Atomic-25-20170407.0`` | ``RC-20170407.0`` | ``25`` | ``20170407.0`` | -+----------------------------+-------------------+--------------+------------------+ -| ``F-Atomic-25-20170407.0`` | ``-`` | ``25`` | ``20170407.0`` | -+----------------------------+-------------------+--------------+------------------+ ++----------------------------+-------------------+--------------+--------------+--------+------------------+ +| Compose ID | Label | Version | Date | Respin | Release | ++============================+===================+==============+==============+========+==================+ +| ``F-Rawhide-20170406.n.0`` | ``-`` | ``Rawhide`` | ``20170406`` | ``0`` | ``20170406.n.0`` | ++----------------------------+-------------------+--------------+--------------+--------+------------------+ +| ``F-26-20170329.1`` | ``Alpha-1.6`` | ``26_Alpha`` | ``20170329`` | ``1`` | ``1.6`` | ++----------------------------+-------------------+--------------+--------------+--------+------------------+ +| ``F-Atomic-25-20170407.0`` | ``RC-20170407.0`` | ``25`` | ``20170407`` | ``0`` | ``20170407.0`` | ++----------------------------+-------------------+--------------+--------------+--------+------------------+ +| ``F-Atomic-25-20170407.0`` | ``-`` | ``25`` | ``20170407`` | ``0`` | ``20170407.0`` | ++----------------------------+-------------------+--------------+--------------+--------+------------------+ All non-``RC`` milestones from label get appended to the version. For release either label is used or date, type and respin. @@ -1230,6 +1230,8 @@ repository with a new commit. * ``version`` -- (*str*) Version string to be added as versioning metadata. If this option is set to ``!OSTREE_VERSION_FROM_LABEL_DATE_TYPE_RESPIN``, a value will be generated automatically as ``$VERSION.$RELEASE``. + If this option is set to ``!VERSION_FROM_VERSION_DATE_RESPIN``, + a value will be generated automatically as ``$VERSION.$DATE.$RESPIN``. :ref:`See how those values are created `. * ``tag_ref`` -- (*bool*, default ``True``) If set to ``False``, a git reference will not be created. diff --git a/pungi/util.py b/pungi/util.py index 0607b6cf..2d2df820 100644 --- a/pungi/util.py +++ b/pungi/util.py @@ -784,9 +784,10 @@ def version_generator(compose, gen): return '%s.%s' % (compose.image_version, compose.image_release) elif gen == '!RELEASE_FROM_LABEL_DATE_TYPE_RESPIN': return compose.image_release - elif gen == '!RELEASE_FROM_VERSION_COMPOSE_ID': - return '%s.%s' % (compose.ci_base.release.version, - compose.ci_base.id) + elif gen == '!VERSION_FROM_VERSION_DATE_RESPIN': + return '%s.%s.%s' % (compose.ci_base.release.version, + compose.ci_base.date, + compose.compose_respin) elif gen and gen[0] == '!': raise RuntimeError("Unknown version generator '%s'" % gen) return gen diff --git a/tests/test_util.py b/tests/test_util.py index 32096767..e0dd2b1e 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -614,6 +614,7 @@ class TestVersionGenerator(unittest.TestCase): self.compose = mock.MagicMock() self.compose.ci_base = ci + self.compose.compose_respin = 0 def test_unknown_generator(self): compose = mock.Mock() @@ -631,9 +632,9 @@ class TestVersionGenerator(unittest.TestCase): compose = mock.Mock() self.assertEqual(util.version_generator(compose, None), None) - def test_release_from_version_compose_id(self): - self.assertEqual(util.version_generator(self.compose, '!RELEASE_FROM_VERSION_COMPOSE_ID'), - '8.RHEL-8.0-20180101.0') + def test_release_from_version_date_respin(self): + self.assertEqual(util.version_generator(self.compose, '!VERSION_FROM_VERSION_DATE_RESPIN'), + '8.20160101.0') class TestTZOffset(unittest.TestCase):