summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-12-10 18:56:42 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-12-10 18:59:50 +0900
commit839ef77400635bac930344d1f5f3ba3cbb682139 (patch)
tree26696ced20508b09b1809dd2c17388a3b40e254b
parentdc85c5e7507cffb6cfa6185d599033ab4404e980 (diff)
downloadbuildstream-839ef77400635bac930344d1f5f3ba3cbb682139.tar.gz
plugins/sources/git.py: Avoid downloading unused submodules
Currently we have configuration in place to disable use of submodules, with the `checkout-submodules` git plugin option and the individual `checkout` options for each submodule, but these unused submodules are still downloaded at fetch time. This patch fixes the plugin to just completely ignore the submodules which are configured to be unused. This was previously fixed in the master branch by !996, and this patch backports the relevant fix to the 1.2 branch, fixing issue #804.
-rw-r--r--buildstream/plugins/sources/git.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index de0376776..1ff2f3287 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -421,13 +421,7 @@ class GitSource(Source):
with self.timed_activity("Staging {}".format(self.mirror.url), silent_nested=True):
self.mirror.stage(directory)
for mirror in self.submodules:
- if mirror.path in self.submodule_checkout_overrides:
- checkout = self.submodule_checkout_overrides[mirror.path]
- else:
- checkout = self.checkout_submodules
-
- if checkout:
- mirror.stage(directory)
+ mirror.stage(directory)
def get_source_fetchers(self):
yield self.mirror
@@ -465,6 +459,10 @@ class GitSource(Source):
#
for path, url in self.mirror.submodule_list():
+ # Completely ignore submodules which are disabled for checkout
+ if self.ignore_submodule(path):
+ continue
+
# Allow configuration to override the upstream
# location of the submodules.
override_url = self.submodule_overrides.get(path)
@@ -478,6 +476,16 @@ class GitSource(Source):
self.submodules = submodules
+ # Checks whether the plugin configuration has explicitly
+ # configured this submodule to be ignored
+ def ignore_submodule(self, path):
+ try:
+ checkout = self.submodule_checkout_overrides[path]
+ except KeyError:
+ checkout = self.checkout_submodules
+
+ return not checkout
+
# Plugin entry point
def setup():