From: Thibaut VARÈNE Date: Thu, 27 Oct 2022 08:20:39 +0000 (+0200) Subject: phase1: fix ForceBuild validation logic X-Git-Tag: v2~14 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=df9bf83b38a48928307a87ea40e511e148b2e343;p=buildbot.git phase1: fix ForceBuild validation logic 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 --- diff --git a/phase1/master.cfg b/phase1/master.cfg index 2b1b72a..1de168a 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -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