diff options
Diffstat (limited to 'bitbake/lib/bb/tests/fetch.py')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 0091723601..077472b8b3 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -2238,6 +2238,33 @@ class GitShallowTest(FetcherTest): | |||
2238 | self.assertIn("Unable to find revision v0.0 even from upstream", cm.output[0]) | 2238 | self.assertIn("Unable to find revision v0.0 even from upstream", cm.output[0]) |
2239 | 2239 | ||
2240 | @skipIfNoNetwork() | 2240 | @skipIfNoNetwork() |
2241 | def test_git_shallow_fetch_premirrors(self): | ||
2242 | url = "git://git.openembedded.org/bitbake;branch=master;protocol=https" | ||
2243 | |||
2244 | # Create a separate premirror directory within tempdir | ||
2245 | premirror = os.path.join(self.tempdir, "premirror") | ||
2246 | os.mkdir(premirror) | ||
2247 | |||
2248 | # Fetch a non-shallow clone into the premirror subdir | ||
2249 | self.d.setVar('BB_GIT_SHALLOW', '0') | ||
2250 | self.d.setVar("DL_DIR", premirror) | ||
2251 | fetcher, ud = self.fetch(url) | ||
2252 | |||
2253 | # Fetch a shallow clone from the premirror subdir with unpacking | ||
2254 | # using the original recipe URL and the premirror mapping | ||
2255 | self.d.setVar('BB_GIT_SHALLOW', '1') | ||
2256 | self.d.setVar("DL_DIR", self.dldir) | ||
2257 | self.d.setVar('BB_FETCH_PREMIRRORONLY', '1') | ||
2258 | self.d.setVar('BB_NO_NETWORK', '1') | ||
2259 | self.d.setVar('BB_GENERATE_MIRROR_TARBALLS', '0') | ||
2260 | self.d.setVar("PREMIRRORS", "git://.*/.* git://{0};protocol=file".format(premirror + "/git2/" + ud.host + ud.path.replace("/", "."))) | ||
2261 | fetcher = self.fetch_and_unpack(url) | ||
2262 | |||
2263 | # Verify that the unpacked sources are shallow clones | ||
2264 | self.assertRevCount(1) | ||
2265 | assert os.path.exists(os.path.join(self.gitdir, '.git', 'shallow')) | ||
2266 | |||
2267 | @skipIfNoNetwork() | ||
2241 | def test_bitbake(self): | 2268 | def test_bitbake(self): |
2242 | self.git('remote add --mirror=fetch origin https://github.com/openembedded/bitbake', cwd=self.srcdir) | 2269 | self.git('remote add --mirror=fetch origin https://github.com/openembedded/bitbake', cwd=self.srcdir) |
2243 | self.git('config core.bare true', cwd=self.srcdir) | 2270 | self.git('config core.bare true', cwd=self.srcdir) |
@@ -2281,6 +2308,19 @@ class GitShallowTest(FetcherTest): | |||
2281 | self.assertRevCount(1) | 2308 | self.assertRevCount(1) |
2282 | assert os.path.exists(os.path.join(self.gitdir, '.git', 'shallow')) | 2309 | assert os.path.exists(os.path.join(self.gitdir, '.git', 'shallow')) |
2283 | 2310 | ||
2311 | def test_shallow_succeeds_with_tag_containing_slash(self): | ||
2312 | self.add_empty_file('a') | ||
2313 | self.add_empty_file('b') | ||
2314 | self.git('tag t1/t2/t3', cwd=self.srcdir) | ||
2315 | self.assertRevCount(2, cwd=self.srcdir) | ||
2316 | |||
2317 | srcrev = self.git('rev-parse HEAD', cwd=self.srcdir).strip() | ||
2318 | self.d.setVar('SRCREV', srcrev) | ||
2319 | uri = self.d.getVar('SRC_URI').split()[0] | ||
2320 | uri = '%s;tag=t1/t2/t3' % uri | ||
2321 | self.fetch_shallow(uri) | ||
2322 | self.assertRevCount(1) | ||
2323 | |||
2284 | class GitLfsTest(FetcherTest): | 2324 | class GitLfsTest(FetcherTest): |
2285 | def skipIfNoGitLFS(): | 2325 | def skipIfNoGitLFS(): |
2286 | if not shutil.which('git-lfs'): | 2326 | if not shutil.which('git-lfs'): |