phase1: fix ForceBuild validation logic
authorThibaut VARÈNE <hacks@slashdirt.org>
Thu, 27 Oct 2022 08:20:39 +0000 (10:20 +0200)
committerPetr Štetiar <ynezz@true.cz>
Mon, 15 May 2023 15:36:01 +0000 (17:36 +0200)
We shouldn't use the local GitPoller repo to find the commit hash of a
tag, since this repo may not yet have been updated at the time the new
tag value is fetched from the remote repo.

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
phase1/master.cfg

index 2b1b72a718537e6c814828b2ec687b327721eca0..1de168a047e8e32c23087cd2567bf13cb34108ff 100644 (file)
@@ -300,8 +300,7 @@ class TagChoiceParameter(BaseParameter):
                super().__init__(name, label, **kw)
                self._choice_list = []
 
-       @property
-       def choices(self):
+       def getRevTags(self, findtag=None):
                taglist = []
                branchvers = []
 
@@ -320,14 +319,21 @@ class TagChoiceParameter(BaseParameter):
                        if not line:
                                break
 
-                       (ref, tag) = line.split()
+                       (rev, tag) = line.split()
 
                        tagver = re.search(r'\brefs/tags/(v[0-9]+\.[0-9]+\.[0-9]+(?:-rc[0-9]+)?)$', tag.decode().strip())
 
                        # only list tags matching configured branches
                        if tagver and any(tagver[1][1:].startswith(b) for b in branchvers):
-                               taglist.append(tagver[1])
+                               if findtag and findtag != tagver[1]:
+                                       continue
+                               taglist.append({'rev': rev.decode().strip(), 'tag': tagver[1]})
+
+               return taglist
 
+       @property
+       def choices(self):
+               taglist = [rt['tag'] for rt in self.getRevTags()]
                taglist.sort(reverse=True, key=lambda tag: tag if re.search(r'-rc[0-9]+$', tag) else tag + '-z')
                taglist.insert(0, '')
 
@@ -340,14 +346,12 @@ class TagChoiceParameter(BaseParameter):
                properties[self.name] = tag
 
                # find the commit matching the tag
-               findrev = subprocess.Popen(['git', 'rev-parse', 'tags/'+tag], stdout=subprocess.PIPE, cwd=work_dir+'/work.git')
-               findrev.wait(timeout=10)
-               line = findrev.stdout.readline()
+               findtag = self.getRevTags(tag)
 
-               if findrev.returncode!=0 or not line:
+               if not findtag:
                        raise ValidationError("Couldn't find tag")
 
-               properties['force_revision'] = line.decode().strip()
+               properties['force_revision'] = findtag[0]['rev']
 
                # find the branch matching the tag
                branch = None