summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2025-04-02 09:00:13 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-04-03 11:03:43 +0100
commit49ec431d9598a9a51bd08a15ee8ceb793042c3d3 (patch)
treed2de91d0ba66fa5dcd61bf5a70905f1a0bb6c9d8 /bitbake
parentefe76a50952af602b60d1e7bf7413225ce92fd68 (diff)
downloadpoky-49ec431d9598a9a51bd08a15ee8ceb793042c3d3.tar.gz
bitbake: fetch2/git: Handle srcrevs for annotated tags in tag check
If SRCREV points at an annotated tag, the comparision code can fail as the resolved tag might not be the same sha. Handle this by also resolving the SRCREV. We only need to do this if they don't match in the first place for a minor performance win. Also add a test for this. (Bitbake rev: 136c06e251de68ed64355ec6b47a522ff3a372e3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/git.py7
-rw-r--r--bitbake/lib/bb/tests/fetch.py7
2 files changed, 13 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 3a4ae6df45..5f4ec6128c 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -730,7 +730,12 @@ class Git(FetchMethod):
730 output = runfetchcmd("%s rev-list -n 1 %s" % (ud.basecmd, ud.parm['tag']), d, workdir=destdir) 730 output = runfetchcmd("%s rev-list -n 1 %s" % (ud.basecmd, ud.parm['tag']), d, workdir=destdir)
731 output = output.strip() 731 output = output.strip()
732 if output != ud.revision: 732 if output != ud.revision:
733 raise bb.fetch2.FetchError("The revision the git tag '%s' resolved to didn't match the SRCREV in use (%s vs %s)" % (ud.parm['tag'], output, ud.revision), ud.url) 733 # It is possible ud.revision is the revision on an annotated tag which won't match the output of rev-list
734 # If it resolves to the same thing there isn't a problem.
735 output2 = runfetchcmd("%s rev-list -n 1 %s" % (ud.basecmd, ud.revision), d, workdir=destdir)
736 output2 = output2.strip()
737 if output != output2:
738 raise bb.fetch2.FetchError("The revision the git tag '%s' resolved to didn't match the SRCREV in use (%s vs %s)" % (ud.parm['tag'], output, ud.revision), ud.url)
734 739
735 repourl = self._get_repo_url(ud) 740 repourl = self._get_repo_url(ud)
736 runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, shlex.quote(repourl)), d, workdir=destdir) 741 runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, shlex.quote(repourl)), d, workdir=destdir)
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 65339d1bb1..4b5439f525 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -3139,6 +3139,13 @@ class GitTagVerificationTests(FetcherTest):
3139 fetcher.download() 3139 fetcher.download()
3140 fetcher.unpack(self.unpackdir) 3140 fetcher.unpack(self.unpackdir)
3141 3141
3142 def test_annotated_tag_rev_match(self):
3143 # Test a url with rev= and tag= set works
3144 # rev is the annotated tag revision in this case
3145 fetcher = bb.fetch.Fetch(["git://git.openembedded.org/bitbake;branch=2.8;protocol=https;rev=6d363159e4b7dc566fc40d069b2615e61774a7d8;tag=2.8.7"], self.d)
3146 fetcher.download()
3147 fetcher.unpack(self.unpackdir)
3148
3142 @skipIfNoNetwork() 3149 @skipIfNoNetwork()
3143 def test_tag_rev_match2(self): 3150 def test_tag_rev_match2(self):
3144 # Test a url with SRCREV and tag= set works 3151 # Test a url with SRCREV and tag= set works