summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-03-21 22:03:41 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-03-22 00:58:19 +0900
commitd246403e584969bcdac4a2d87ad64aaeab2ac850 (patch)
treeba3cf49b5cfb250cce66e5a3db0b51c460a19f54
parent41274b2d811d7106960d92fe095da31eb32f8cc9 (diff)
downloadbuildstream-d246403e584969bcdac4a2d87ad64aaeab2ac850.tar.gz
git.py source plugin: Ignore inconsistent submodules.
If a submodule is listed in either the buildstream git source definition, or in the .gitmodules file; but is not a valid submodule which was added with `git submodule add`, we now emit a warning and avoid exploding in the user's face. This fixes issue #299
-rw-r--r--buildstream/plugins/sources/git.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index 3d10f69f6..97643439e 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -227,8 +227,14 @@ class GitMirror():
return submodule_commit
else:
- raise SourceError("{}: Failed to read commit information for submodule '{}'"
- .format(self.source, submodule))
+ detail = "The submodule '{}' is defined either in the BuildStream source\n".format(submodule) + \
+ "definition, or in a .gitmodules file. But the submodule was never added to the\n" + \
+ "underlying git repository with `git submodule add`."
+
+ self.source.warn("{}: Ignoring inconsistent submodule '{}'"
+ .format(self.source, submodule), detail=detail)
+
+ return None
class GitSource(Source):
@@ -401,8 +407,9 @@ class GitSource(Source):
url = override_url
ref = self.mirror.submodule_ref(path)
- mirror = GitMirror(self, path, url, ref)
- submodules.append(mirror)
+ if ref is not None:
+ mirror = GitMirror(self, path, url, ref)
+ submodules.append(mirror)
self.submodules = submodules