fetch2/git: fix shallow clone for tag containing slash
PATCH v2 1/2 fetch2/git: fix shallow clone for tag containing slash
From: Chen Qi <[email protected]>
If a tag contains slash, e.g., debian/5.22, then shallow clone fails because it's using a wrong ref.
To reproduce the issue, add the following lines in local.conf:
BB_GIT_SHALLOW = "1"
BB_GENERATE_SHALLOW_TARBALLS = "1"
And then run 'bitbake debianutils -c fetch'.
What the original os.path.basename(ref) wanted to do is to remove the strings such as refs/heads/. So we do it explitly to fix this issue.
--- bitbake/lib/bb/fetch2/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/fetch2/git.py +1 -1
@@ -639,7 +639,7 @@ class Git(FetchMethod): extra_refs.append(r) for ref in extra_refs: - ref_fetch = os.path.basename(ref) + ref_fetch = ref.replace('refs/heads/', '').replace('refs/remotes/origin/', '').replace('refs/tags/', '') runfetchcmd("%s fetch origin --depth 1 %s" % (ud.basecmd, ref_fetch), d, workdir=dest) revision = runfetchcmd("%s rev-parse FETCH_HEAD" % ud.basecmd, d, workdir=dest) runfetchcmd("%s update-ref %s %s" % (ud.basecmd, ref, revision), d, workdir=dest)
Signature · 1 line
2.34.1
PATCH v2 2/2 lib/bb/tests/fetch: add a test case to ensure git shallow fetch works for tag containing slash
From: Chen Qi <[email protected]>
Add a test case to ensure git shallow fetch succeeds for SRC_URI with tag containing slash.
For example, we want to succeed for SRC_URI like below:SRC_URI = "git://salsa.debian.org/debian/debianutils.git;protocol=https;branch=master;tag=debian/${PV}"
See the following link for more information:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=15862
--- bitbake/lib/bb/tests/fetch.py | 13 +++++++++++++ 1 file changed, 13 insertions(+)
bitbake/lib/bb/tests/fetch.py +13 -0
@@ -2281,6 +2281,19 @@ class GitShallowTest(FetcherTest): self.assertRevCount(1) assert os.path.exists(os.path.join(self.gitdir, '.git', 'shallow')) + def test_shallow_succeeds_with_tag_containing_slash(self): + self.add_empty_file('a') + self.add_empty_file('b') + self.git('tag t1/t2/t3', cwd=self.srcdir) + self.assertRevCount(2, cwd=self.srcdir) + + srcrev = self.git('rev-parse HEAD', cwd=self.srcdir).strip() + self.d.setVar('SRCREV', srcrev) + uri = self.d.getVar('SRC_URI').split()[0] + uri = '%s;tag=t1/t2/t3' % uri + self.fetch_shallow(uri) + self.assertRevCount(1) + class GitLfsTest(FetcherTest): def skipIfNoGitLFS(): if not shutil.which('git-lfs'):
Signature · 1 line
2.34.1