From 02510ec2ff9e83666a35d1b1bc479909b260034a Mon Sep 17 00:00:00 2001 From: Anastasis Andronidis Date: Thu, 6 Sep 2012 15:18:29 +0300 Subject: [PATCH] --version is now taking the correct head --- lib/ansible/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index 9bf489a508..58b085a26f 100644 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -328,10 +328,12 @@ def _gitinfo(): # 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): try: - central_gitdir = yaml.load(open(repo_path)).get('gitdir').split('.git')[0] - repo_path = repo_path.split('.git')[0] + gitdir = yaml.load(open(repo_path)).get('gitdir') # There is a posibility the .git file to have an absolute path. - repo_path = os.path.join(repo_path, os.path.relpath(central_gitdir), '.git') + if os.path.isabs(gitdir): + repo_path = gitdir + else: + repo_path = os.path.join(repo_path.split('.git')[0], gitdir) except (IOError, AttributeError): return '' f = open(os.path.join(repo_path, "HEAD"))