Add support for RHEL style module stream branch names

Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
This commit is contained in:
Merlin Mathesius 2021-05-12 15:47:01 -05:00 committed by carlwgeorge
parent 615d8f3e38
commit bb525ad895
2 changed files with 48 additions and 1 deletions

View file

@ -45,13 +45,20 @@ class DistGitDirectory(object):
if repo_path: if repo_path:
# self.repo = git.cmd.Git(repo_path) # self.repo = git.cmd.Git(repo_path)
self.repo = git.repo.Repo(repo_path) self.repo = git.repo.Repo(repo_path)
rhelbranchre = r'rhel-(?P<major>\d+)\.(?P<minor>\d+)(?:\.(?P<appstream>\d+))?'
sigtobranchre = r'c(?P<centosversion>\d+[s]?)-sig-(?P<signame>\w+)-?(?P<projectname>\w+)?-?(?P<releasename>\w+)?' sigtobranchre = r'c(?P<centosversion>\d+[s]?)-sig-(?P<signame>\w+)-?(?P<projectname>\w+)?-?(?P<releasename>\w+)?'
distrobranchre = r'c(?P<centosversion>\d+)-?(?P<projectname>\w+)?' distrobranchre = r'c(?P<centosversion>\d+)-?(?P<projectname>\w+)?'
oldbranchre = r'(?P<signame>\w+)(?P<centosversion>\d)' oldbranchre = r'(?P<signame>\w+)(?P<centosversion>\d)'
rhelmatch = re.search(rhelbranchre, branchtext)
sigmatch = re.match(sigtobranchre, branchtext) sigmatch = re.match(sigtobranchre, branchtext)
distromatch = re.match(distrobranchre, branchtext) distromatch = re.match(distrobranchre, branchtext)
oldbranchmatch = re.match(oldbranchre, 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() gd = sigmatch.groupdict()
self.signame = gd['signame'] self.signame = gd['signame']
self.centosversion = gd['centosversion'] self.centosversion = gd['centosversion']

View file

@ -140,6 +140,46 @@ class TestDistgitC7DistroBranch(unittest.TestCase):
def test_target_gets_set(self): def test_target_gets_set(self):
self.assertEqual(self.d.target, 'c7') 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): class TestDistgitC6DistroBranch(unittest.TestCase):
def setUp(self): def setUp(self):
self.branchstring = 'c6' self.branchstring = 'c6'