From bb525ad89551ecb8f62d3ac67ff940e04f379797 Mon Sep 17 00:00:00 2001 From: Merlin Mathesius Date: Jun 08 2021 19:24:17 +0000 Subject: Add support for RHEL style module stream branch names Signed-off-by: Merlin Mathesius --- diff --git a/src/centpkg/__init__.py b/src/centpkg/__init__.py index e311c9a..8653930 100644 --- a/src/centpkg/__init__.py +++ b/src/centpkg/__init__.py @@ -45,13 +45,20 @@ class DistGitDirectory(object): if repo_path: # self.repo = git.cmd.Git(repo_path) self.repo = git.repo.Repo(repo_path) + rhelbranchre = r'rhel-(?P\d+)\.(?P\d+)(?:\.(?P\d+))?' sigtobranchre = r'c(?P\d+[s]?)-sig-(?P\w+)-?(?P\w+)?-?(?P\w+)?' distrobranchre = r'c(?P\d+)-?(?P\w+)?' oldbranchre = r'(?P\w+)(?P\d)' + rhelmatch = re.search(rhelbranchre, branchtext) sigmatch = re.match(sigtobranchre, branchtext) distromatch = re.match(distrobranchre, branchtext) oldbranchmatch = re.match(oldbranchre, branchtext) - if sigmatch: + if rhelmatch: + gd = rhelmatch.groupdict() + self.distrobranch = True + self.signame = 'centos' + self.centosversion = gd['major'] + elif sigmatch: gd = sigmatch.groupdict() self.signame = gd['signame'] self.centosversion = gd['centosversion'] diff --git a/tests/test_distgit.py b/tests/test_distgit.py index 96142ff..5519a78 100644 --- a/tests/test_distgit.py +++ b/tests/test_distgit.py @@ -140,6 +140,46 @@ class TestDistgitC7DistroBranch(unittest.TestCase): def test_target_gets_set(self): self.assertEqual(self.d.target, 'c7') +class TestDistgitStream9Module(unittest.TestCase): + def setUp(self): + self.branchstring = '3.0-rhel-9.0.0-beta' + self.d = DistGitDirectory(self.branchstring) + + def test_signame_gets_set(self): + self.assertEqual(self.d.signame, 'centos') + + def test_centosversion_gets_set(self): + self.assertEqual(self.d.centosversion, '9') + + def test_projectname_gets_set(self): + self.assertEqual(self.d.projectname, None) + + def test_releasename_gets_set(self): + self.assertEqual(self.d.releasename, None) + + def test_target_gets_set(self): + self.assertEqual(self.d.target, 'c9s-candidate') + +class TestDistgitStream9ModuleComponent(unittest.TestCase): + def setUp(self): + self.branchstring = 'stream-container-tools-3.0-rhel-9.0.0-beta' + self.d = DistGitDirectory(self.branchstring) + + def test_signame_gets_set(self): + self.assertEqual(self.d.signame, 'centos') + + def test_centosversion_gets_set(self): + self.assertEqual(self.d.centosversion, '9') + + def test_projectname_gets_set(self): + self.assertEqual(self.d.projectname, None) + + def test_releasename_gets_set(self): + self.assertEqual(self.d.releasename, None) + + def test_target_gets_set(self): + self.assertEqual(self.d.target, 'c9s-candidate') + class TestDistgitC6DistroBranch(unittest.TestCase): def setUp(self): self.branchstring = 'c6'