[buildbot] phase1: fix ForceBuild validation logic

LEDE Commits lede-commits at lists.infradead.org
Mon May 15 08:39:41 PDT 2023


ynezz pushed a commit to buildbot.git, branch master:
https://git.openwrt.org/df9bf83b38a48928307a87ea40e511e148b2e343

commit df9bf83b38a48928307a87ea40e511e148b2e343
Author: Thibaut VARÈNE <hacks at slashdirt.org>
AuthorDate: Thu Oct 27 10:20:39 2022 +0200

    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 <hacks at slashdirt.org>
---
 phase1/master.cfg | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

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




More information about the lede-commits mailing list