diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-03-18 11:04:21 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-03-19 11:46:30 +0000 |
commit | 18a533bfe6d4d5020c0252f9aecf6fc4abda672e (patch) | |
tree | f59f92b430d1f39fcdb250927314e11d9e715051 /bitbake/lib/bb/fetch2/git.py | |
parent | e8e34a04ce283bd41591dcc6ae8d6e8094d489e0 (diff) | |
download | poky-18a533bfe6d4d5020c0252f9aecf6fc4abda672e.tar.gz |
bitbake: fetch/git: Rework tag parameter handling
Currently bitbake disallows tag parameters along with revision parameters.
This isn't great since quite often, we'd like to verify that a given revision
does match some tag. At the same time we don't want to or need to access
the network to verify this, which normally a tag would require.
Rework the code so that tag and revisions can both be specified together.
Verify that any tag specified matches the revision in use at unpack time.
This means we can start requiring people to put tags in git SRC_URIs
when revisions are used, making review a little easier that it isn't
some random revision.
The test that is dropped looks like a different test but the comment
is a copy and paste error. The SRCREV/rev mismatch test remains, this
removes the rev and tag set test.
(Bitbake rev: d591d7633fe8d739ec00395920e44910b0b77e27)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/git.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index a73fb79ac8..53fdc4c3df 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -279,6 +279,10 @@ class Git(FetchMethod): | |||
279 | ud.unresolvedrev[name] = ud.revisions[name] | 279 | ud.unresolvedrev[name] = ud.revisions[name] |
280 | ud.revisions[name] = self.latest_revision(ud, d, name) | 280 | ud.revisions[name] = self.latest_revision(ud, d, name) |
281 | 281 | ||
282 | if 'tag' in ud.parm: | ||
283 | if len(ud.revisions) != 1: | ||
284 | raise bb.fetch2.ParameterError("Git fetcher support for multiple tagged revisions not implemented", ud.url) | ||
285 | |||
282 | gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.').replace(' ','_').replace('(', '_').replace(')', '_')) | 286 | gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.').replace(' ','_').replace('(', '_').replace(')', '_')) |
283 | if gitsrcname.startswith('.'): | 287 | if gitsrcname.startswith('.'): |
284 | gitsrcname = gitsrcname[1:] | 288 | gitsrcname = gitsrcname[1:] |
@@ -747,6 +751,14 @@ class Git(FetchMethod): | |||
747 | if not source_found: | 751 | if not source_found: |
748 | raise bb.fetch2.UnpackError("No up to date source found: " + "; ".join(source_error), ud.url) | 752 | raise bb.fetch2.UnpackError("No up to date source found: " + "; ".join(source_error), ud.url) |
749 | 753 | ||
754 | # If there is a tag parameter in the url and we also have a fixed srcrev, check the tag | ||
755 | # matches the revision | ||
756 | if 'tag' in ud.parm and sha1_re.match(ud.revision): | ||
757 | output = runfetchcmd("%s rev-list -n 1 %s" % (ud.basecmd, ud.parm['tag']), d, workdir=destdir) | ||
758 | output = output.strip() | ||
759 | if output != ud.revision: | ||
760 | 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) | ||
761 | |||
750 | repourl = self._get_repo_url(ud) | 762 | repourl = self._get_repo_url(ud) |
751 | runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, shlex.quote(repourl)), d, workdir=destdir) | 763 | runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, shlex.quote(repourl)), d, workdir=destdir) |
752 | 764 | ||