summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Barker <pbarker@konsulko.com>2020-03-09 13:52:13 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-03-11 14:43:21 +0000
commit2e26e97129d4c54bf86cdea8f9791696a06a36b4 (patch)
treebc29f250d78c0b9b71bec657b4cffb9ada8513ce
parent3987db953e414255ce278bc25a5f6cec0f2a30c7 (diff)
downloadbitbake-2e26e97129d4c54bf86cdea8f9791696a06a36b4.tar.gz
tests: Add test for gitsm fetcher with shallow mirror tarballs
Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/tests/fetch.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 45dc9e5d0..d0c161a7f 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -1691,6 +1691,47 @@ class GitShallowTest(FetcherTest):
# Verify the submodule is also shallow
self.assertRevCount(1, cwd=os.path.join(self.gitdir, 'gitsubmodule'))
+ def test_shallow_submodule_mirrors(self):
+ self.add_empty_file('a')
+ self.add_empty_file('b')
+
+ smdir = os.path.join(self.tempdir, 'gitsubmodule')
+ bb.utils.mkdirhier(smdir)
+ self.git('init', cwd=smdir)
+ # Make this look like it was cloned from a remote...
+ self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir)
+ self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir)
+ self.add_empty_file('asub', cwd=smdir)
+ self.add_empty_file('bsub', cwd=smdir)
+
+ self.git('submodule init', cwd=self.srcdir)
+ self.git('submodule add file://%s' % smdir, cwd=self.srcdir)
+ self.git('submodule update', cwd=self.srcdir)
+ self.git('commit -m submodule -a', cwd=self.srcdir)
+
+ uri = 'gitsm://%s;protocol=file;subdir=${S}' % self.srcdir
+
+ # Fetch once to generate the shallow tarball
+ fetcher, ud = self.fetch(uri)
+
+ # Set up the mirror
+ mirrordir = os.path.join(self.tempdir, 'mirror')
+ os.rename(self.dldir, mirrordir)
+ self.d.setVar('PREMIRRORS', 'gitsm://.*/.* file://%s/\n' % mirrordir)
+
+ # Fetch from the mirror
+ bb.utils.remove(self.dldir, recurse=True)
+ bb.utils.remove(self.gitdir, recurse=True)
+ self.fetch_and_unpack(uri)
+
+ # Verify the main repository is shallow
+ self.assertRevCount(1)
+
+ # Verify the gitsubmodule directory is present
+ assert os.listdir(os.path.join(self.gitdir, 'gitsubmodule'))
+
+ # Verify the submodule is also shallow
+ self.assertRevCount(1, cwd=os.path.join(self.gitdir, 'gitsubmodule'))
if any(os.path.exists(os.path.join(p, 'git-annex')) for p in os.environ.get('PATH').split(':')):
def test_shallow_annex(self):