summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-04-03 22:33:06 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-04-04 12:26:46 +0100
commitb1d2bd3308e5e99c72d1d56a1a03ed4de0b76de0 (patch)
treec550d74f6bbbe9096e6f1cba16399560371a5030
parentdcf87fd1f2c180045f16c8fac3234ff982ce38e3 (diff)
downloadmorph-b1d2bd3308e5e99c72d1d56a1a03ed4de0b76de0.tar.gz
morphlib/git: Ignore not valid submodules
Some repositories may have submodules listed in .gitmodules that are not pointing to a commit object in the tree. This was causing the following error: ERROR: /srv/distbuild/gits/git___git_foo_bar_git:c36652c7dd9f1687c87ce04ad3d4af2beb52dc25:.gitmodules: No commit object found for submodule "codegen" Instead of raising that error, capture it and ignore the submodule. Change-Id: Iba0428feea7605f797dc78e3e250f3d66c003670
-rw-r--r--morphlib/git.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/morphlib/git.py b/morphlib/git.py
index 12c24b0e..65ec4f40 100644
--- a/morphlib/git.py
+++ b/morphlib/git.py
@@ -94,9 +94,16 @@ class Submodules(object):
name = re.sub(section_pattern, r'\1', section)
url = parser.get(section, 'url')
path = parser.get(section, 'path')
+ try:
+ sha1 = gd.get_submodule_commit(self.ref, path)
+ except morphlib.gitdir.MissingSubmoduleCommitError:
+ # Ignore submodules listed in .gitmodules file that are
+ # not pointing to a git commit object. If you try to clone
+ # a repo with submodules without a commit object (using
+ # Git), nothing will happen, and Git will not even complain
+ continue
# create a submodule object
- sha1 = gd.get_submodule_commit(self.ref, path)
submodule = Submodule(name, url, sha1, path)
self.submodules.append(submodule)
else: