From 952a36920c745b94e3ef1d3ae41e81364456f296 Mon Sep 17 00:00:00 2001 From: Will Thames Date: Sun, 28 Sep 2014 13:19:56 +1000 Subject: [PATCH] Cater for uninitialized submodules Output a useful message if `git submodule update --init --recursive` not yet performed ``` $ ansible --version ansible 1.8 (submodule_ansible_version 59ae596484) last updated 2014/09/28 13:20:51 (GMT +1000) lib/ansible/modules/core: (detached HEAD 617a52b20d) last updated 2014/09/28 13:15:25 (GMT +1000) lib/ansible/modules/extras: not found - use git submodule update --init lib/ansible/modules/extras ``` --- lib/ansible/utils/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 3f26e0779f..ba65028f9f 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -883,8 +883,11 @@ def _gitinfo(): for line in f: tokens = line.strip().split(' ') if tokens[0] == 'path': - repo_path = tokens[2] - result += "\n {0}: {1}".format(repo_path, _gitrepoinfo(os.path.join(basedir, repo_path, '.git'))) + submodule_path = tokens[2] + submodule_info =_gitrepoinfo(os.path.join(basedir, submodule_path, '.git')) + if not submodule_info: + submodule_info = ' not found - use git submodule update --init ' + submodule_path + result += "\n {0}: {1}".format(submodule_path, submodule_info) f.close() return result