summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests
diff options
context:
space:
mode:
authorChristopher Larson <kergoth@gmail.com>2017-05-13 02:46:30 +0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-02 13:36:57 +0100
commit8144f6f408a77b7fb3367a91c55288b977a9bf88 (patch)
treecae38a559bbda9d1e6aa3cc5b4c5bf9e02d9a69f /bitbake/lib/bb/tests
parentbf87c5cd194b5a24c388d6445b413b5f673bc1de (diff)
downloadpoky-8144f6f408a77b7fb3367a91c55288b977a9bf88.tar.gz
bitbake: fetch/git: add support for keeping extra refs for shallow
By default, all unused refs (branches & tags) are removed from the repository, as shallow processing scales with the number of refs it has to process. Add the ability to explicitly specify additional refs to keep. This is particularly useful for recipes with custom checkout processes, or whose git-based versioning requires a tag be available (i.e. for `git describe --tags`). The new `BB_GIT_SHALLOW_EXTRA_REFS` variable is a space-separated list of refs, fully specified, and support wildcards. Example usages: BB_GIT_SHALLOW_EXTRA_REFS = "refs/tags/v1.0" BB_GIT_SHALLOW_EXTRA_REFS += "refs/heads/*" (Bitbake rev: 1771934cd9f8b5847c6fcae0a906fb99d6b0db16) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r--bitbake/lib/bb/tests/fetch.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 0b0116b455..3e2ce53056 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -1293,6 +1293,48 @@ class GitShallowTest(FetcherTest):
1293 with self.assertRaises(bb.fetch2.FetchError): 1293 with self.assertRaises(bb.fetch2.FetchError):
1294 self.fetch() 1294 self.fetch()
1295 1295
1296 def test_shallow_extra_refs(self):
1297 self.add_empty_file('a')
1298 self.add_empty_file('b')
1299 self.git('branch a_branch', cwd=self.srcdir)
1300 self.assertRefs(['master', 'a_branch'], cwd=self.srcdir)
1301 self.assertRevCount(2, cwd=self.srcdir)
1302
1303 self.d.setVar('BB_GIT_SHALLOW_EXTRA_REFS', 'refs/heads/a_branch')
1304 self.fetch_shallow()
1305
1306 self.assertRefs(['master', 'origin/master', 'origin/a_branch'])
1307 self.assertRevCount(1)
1308
1309 def test_shallow_extra_refs_wildcard(self):
1310 self.add_empty_file('a')
1311 self.add_empty_file('b')
1312 self.git('branch a_branch', cwd=self.srcdir)
1313 self.git('tag v1.0', cwd=self.srcdir)
1314 self.assertRefs(['master', 'a_branch', 'v1.0'], cwd=self.srcdir)
1315 self.assertRevCount(2, cwd=self.srcdir)
1316
1317 self.d.setVar('BB_GIT_SHALLOW_EXTRA_REFS', 'refs/tags/*')
1318 self.fetch_shallow()
1319
1320 self.assertRefs(['master', 'origin/master', 'v1.0'])
1321 self.assertRevCount(1)
1322
1323 def test_shallow_missing_extra_refs(self):
1324 self.add_empty_file('a')
1325 self.add_empty_file('b')
1326
1327 self.d.setVar('BB_GIT_SHALLOW_EXTRA_REFS', 'refs/heads/foo')
1328 with self.assertRaises(bb.fetch2.FetchError):
1329 self.fetch()
1330
1331 def test_shallow_missing_extra_refs_wildcard(self):
1332 self.add_empty_file('a')
1333 self.add_empty_file('b')
1334
1335 self.d.setVar('BB_GIT_SHALLOW_EXTRA_REFS', 'refs/tags/*')
1336 self.fetch()
1337
1296 if os.environ.get("BB_SKIP_NETTESTS") == "yes": 1338 if os.environ.get("BB_SKIP_NETTESTS") == "yes":
1297 print("Unset BB_SKIP_NETTESTS to run network tests") 1339 print("Unset BB_SKIP_NETTESTS to run network tests")
1298 else: 1340 else: