phase1: fix ForceScheduler
authorThibaut VARÈNE <hacks@slashdirt.org>
Wed, 26 Oct 2022 12:43:15 +0000 (14:43 +0200)
committerPetr Štetiar <ynezz@true.cz>
Mon, 15 May 2023 15:36:01 +0000 (17:36 +0200)
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
phase1/master.cfg

index 70e2162b52570e67269692b4f74bb383728fa54d..b65d3af8cd49c760d8ed0ba07c404ba804b812d0 100644 (file)
@@ -297,23 +297,28 @@ class TagChoiceParameter(BaseParameter):
        @property
        def choices(self):
                taglist = []
-               basever = re.search(r'-([0-9]+\.[0-9]+)$', "master")    # XXX FIXME
+               branchvers = []
 
-               if basever:
-                       findtags = subprocess.Popen(
-                               ['git', 'ls-remote', '--tags', repo_url],
-                               stdout = subprocess.PIPE)
+               for b in branchNames:
+                       basever = re.search(r'-([0-9]+\.[0-9]+)$', b)
+                       if basever:
+                               branchvers.append(basever[1])
 
-                       while True:
-                               line = findtags.stdout.readline()
+               alltags = subprocess.Popen(
+                       ['git', 'ls-remote', '--tags', repo_url],
+                       stdout = subprocess.PIPE)
 
-                               if not line:
-                                       break
+               while True:
+                       line = alltags.stdout.readline()
+
+                       if not line:
+                               break
 
-                               tagver = re.search(r'\brefs/tags/v([0-9]+\.[0-9]+\.[0-9]+(?:-rc[0-9]+)?)$', line.decode().strip())
+                       tagver = re.search(r'\brefs/tags/v([0-9]+\.[0-9]+\.[0-9]+(?:-rc[0-9]+)?)$', line.decode().strip())
 
-                               if tagver and tagver[1].find(basever[1]) == 0:
-                                       taglist.append(tagver[1])
+                       # only list tags matching configured branches
+                       if tagver and any(tagver[1].startswith(b) for b in branchvers):
+                               taglist.append(tagver[1])
 
                taglist.sort(reverse=True, key=lambda tag: tag if re.search(r'-rc[0-9]+$', tag) else tag + '-z')
                taglist.insert(0, '')
@@ -369,7 +374,7 @@ c['schedulers'].append(ForceScheduler(
                                        name    = "target",
                                        label   = "Build target",
                                        default = "all",
-                                       choices = set( "all" ) | targets
+                                       choices = [ "all" ] + list(targets)
                                ),
                                TagChoiceParameter(
                                        name    = "tag",