Skip to content
Snippets Groups Projects
Commit 839ef774 authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

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.
parent dc85c5e7
No related branches found
No related tags found
Loading
Pipeline #39550393 passed
......@@ -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():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment