bitbake: tests/fetch: Add test case to check shallow cloning using PREMIRRORS

(Bitbake rev: 6e1434d93d489aa4bab07777a7a9dc58ba0ca5a7)

Signed-off-by: Stefan Koch <stefan-koch@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Koch, Stefan 2025-05-27 11:59:03 +02:00 committed by Richard Purdie
parent f5ae37fbd8
commit d8b0adfaac

View File

@ -2237,6 +2237,33 @@ class GitShallowTest(FetcherTest):
self.fetch_shallow()
self.assertIn("Unable to find revision v0.0 even from upstream", cm.output[0])
@skipIfNoNetwork()
def test_git_shallow_fetch_premirrors(self):
url = "git://git.openembedded.org/bitbake;branch=master;protocol=https"
# Create a separate premirror directory within tempdir
premirror = os.path.join(self.tempdir, "premirror")
os.mkdir(premirror)
# Fetch a non-shallow clone into the premirror subdir
self.d.setVar('BB_GIT_SHALLOW', '0')
self.d.setVar("DL_DIR", premirror)
fetcher, ud = self.fetch(url)
# Fetch a shallow clone from the premirror subdir with unpacking
# using the original recipe URL and the premirror mapping
self.d.setVar('BB_GIT_SHALLOW', '1')
self.d.setVar("DL_DIR", self.dldir)
self.d.setVar('BB_FETCH_PREMIRRORONLY', '1')
self.d.setVar('BB_NO_NETWORK', '1')
self.d.setVar('BB_GENERATE_MIRROR_TARBALLS', '0')
self.d.setVar("PREMIRRORS", "git://.*/.* git://{0};protocol=file".format(premirror + "/git2/" + ud.host + ud.path.replace("/", ".")))
fetcher = self.fetch_and_unpack(url)
# Verify that the unpacked sources are shallow clones
self.assertRevCount(1)
assert os.path.exists(os.path.join(self.gitdir, '.git', 'shallow'))
@skipIfNoNetwork()
def test_bitbake(self):
self.git('remote add --mirror=fetch origin https://github.com/openembedded/bitbake', cwd=self.srcdir)