From b1d2bd3308e5e99c72d1d56a1a03ed4de0b76de0 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Sun, 3 Apr 2016 22:33:06 +0000 Subject: 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 --- morphlib/git.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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: -- cgit v1.2.1