diff mbox series

[v3,3/3] tests/fetch: Add test case to check shallow cloning using `PREMIRRORS`

Message ID 20250527095903.2300556-3-stefan-koch@siemens.com
State New
Headers show
Series [v3,1/3] fetch2: Move the `ensure_symlink()` function into the `FetchMethod` class | expand

Commit Message

Stefan Koch May 27, 2025, 9:59 a.m. UTC
Signed-off-by: Stefan Koch <stefan-koch@siemens.com>
---
 lib/bb/tests/fetch.py | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Richard Purdie May 28, 2025, 1:22 p.m. UTC | #1
On Tue, 2025-05-27 at 11:59 +0200, Koch, Stefan via lists.yoctoproject.org wrote:
> Signed-off-by: Stefan Koch <stefan-koch@siemens.com>
> ---
>  lib/bb/tests/fetch.py | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)

I've merged this series, I just wanted to say thanks for getting to the
bottom of it, getting to a good fix and ensuring the issue doesn't come
back (hopefully!).

Cheers,

Richard
diff mbox series

Patch

diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 3f4233258..077472b8b 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -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)