summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnastasis Andronidis <anastasis90@yahoo.gr>2012-09-04 16:12:39 +0300
committerAnastasis Andronidis <anastasis90@yahoo.gr>2012-09-04 16:12:39 +0300
commit4e94db3d78019f6341afdaef031a26d2e9439727 (patch)
treebaadca6185f87c86767d1678b3e88cc0b0849bd4
parent8f220a4f770db794d9a05c42ebfe3c6b7669deb7 (diff)
downloadansible-4e94db3d78019f6341afdaef031a26d2e9439727.tar.gz
Fixed a parsing HEAD problem, when ansible is checked out as a submodule
Fixed a parsing HEAD problem, when ansible is checked out as a submodule in git
-rw-r--r--lib/ansible/utils.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py
index ca0f1b455d..2f2f63196b 100644
--- a/lib/ansible/utils.py
+++ b/lib/ansible/utils.py
@@ -324,6 +324,11 @@ def _gitinfo():
result = None
repo_path = os.path.join(os.path.dirname(__file__), '..', '..', '.git')
if os.path.exists(repo_path):
+ ''' Check if the .git is a file. If it is a file, it means that we are in a submodule structure. '''
+ if os.path.isfile(repo_path):
+ central_gitdir = yaml.load(open(repo_path))['gitdir'].split('.git')[0]
+ ''' There is a posibility the .git file to have an absolute path. '''
+ repo_path = os.path.join(os.path.relpath(central_gitdir), '.git')
f = open(os.path.join(repo_path, "HEAD"))
branch = f.readline().split('/')[-1].rstrip("\n")
f.close()