Turn COMPOSE_ID version generator into DATE_RESPIN

Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
This commit is contained in:
Patrick Uiterwijk 2017-11-09 16:37:57 +01:00
parent 388be481ea
commit 8181c5be48
3 changed files with 21 additions and 17 deletions

View File

@ -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 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. used to shorten the config and keep it the same for multiple uses.
+----------------------------+-------------------+--------------+------------------+ +----------------------------+-------------------+--------------+--------------+--------+------------------+
| Compose ID | Label | Version | Release | | Compose ID | Label | Version | Date | Respin | Release |
+============================+===================+==============+==================+ +============================+===================+==============+==============+========+==================+
| ``F-Rawhide-20170406.n.0`` | ``-`` | ``Rawhide`` | ``20170406.n.0`` | | ``F-Rawhide-20170406.n.0`` | ``-`` | ``Rawhide`` | ``20170406`` | ``0`` | ``20170406.n.0`` |
+----------------------------+-------------------+--------------+------------------+ +----------------------------+-------------------+--------------+--------------+--------+------------------+
| ``F-26-20170329.1`` | ``Alpha-1.6`` | ``26_Alpha`` | ``1.6`` | | ``F-26-20170329.1`` | ``Alpha-1.6`` | ``26_Alpha`` | ``20170329`` | ``1`` | ``1.6`` |
+----------------------------+-------------------+--------------+------------------+ +----------------------------+-------------------+--------------+--------------+--------+------------------+
| ``F-Atomic-25-20170407.0`` | ``RC-20170407.0`` | ``25`` | ``20170407.0`` | | ``F-Atomic-25-20170407.0`` | ``RC-20170407.0`` | ``25`` | ``20170407`` | ``0`` | ``20170407.0`` |
+----------------------------+-------------------+--------------+------------------+ +----------------------------+-------------------+--------------+--------------+--------+------------------+
| ``F-Atomic-25-20170407.0`` | ``-`` | ``25`` | ``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 All non-``RC`` milestones from label get appended to the version. For release
either label is used or date, type and respin. 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. * ``version`` -- (*str*) Version string to be added as versioning metadata.
If this option is set to ``!OSTREE_VERSION_FROM_LABEL_DATE_TYPE_RESPIN``, If this option is set to ``!OSTREE_VERSION_FROM_LABEL_DATE_TYPE_RESPIN``,
a value will be generated automatically as ``$VERSION.$RELEASE``. 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 <auto-version>`. :ref:`See how those values are created <auto-version>`.
* ``tag_ref`` -- (*bool*, default ``True``) If set to ``False``, a git * ``tag_ref`` -- (*bool*, default ``True``) If set to ``False``, a git
reference will not be created. reference will not be created.

View File

@ -784,9 +784,10 @@ def version_generator(compose, gen):
return '%s.%s' % (compose.image_version, compose.image_release) return '%s.%s' % (compose.image_version, compose.image_release)
elif gen == '!RELEASE_FROM_LABEL_DATE_TYPE_RESPIN': elif gen == '!RELEASE_FROM_LABEL_DATE_TYPE_RESPIN':
return compose.image_release return compose.image_release
elif gen == '!RELEASE_FROM_VERSION_COMPOSE_ID': elif gen == '!VERSION_FROM_VERSION_DATE_RESPIN':
return '%s.%s' % (compose.ci_base.release.version, return '%s.%s.%s' % (compose.ci_base.release.version,
compose.ci_base.id) compose.ci_base.date,
compose.compose_respin)
elif gen and gen[0] == '!': elif gen and gen[0] == '!':
raise RuntimeError("Unknown version generator '%s'" % gen) raise RuntimeError("Unknown version generator '%s'" % gen)
return gen return gen

View File

@ -614,6 +614,7 @@ class TestVersionGenerator(unittest.TestCase):
self.compose = mock.MagicMock() self.compose = mock.MagicMock()
self.compose.ci_base = ci self.compose.ci_base = ci
self.compose.compose_respin = 0
def test_unknown_generator(self): def test_unknown_generator(self):
compose = mock.Mock() compose = mock.Mock()
@ -631,9 +632,9 @@ class TestVersionGenerator(unittest.TestCase):
compose = mock.Mock() compose = mock.Mock()
self.assertEqual(util.version_generator(compose, None), None) self.assertEqual(util.version_generator(compose, None), None)
def test_release_from_version_compose_id(self): def test_release_from_version_date_respin(self):
self.assertEqual(util.version_generator(self.compose, '!RELEASE_FROM_VERSION_COMPOSE_ID'), self.assertEqual(util.version_generator(self.compose, '!VERSION_FROM_VERSION_DATE_RESPIN'),
'8.RHEL-8.0-20180101.0') '8.20160101.0')
class TestTZOffset(unittest.TestCase): class TestTZOffset(unittest.TestCase):