mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #9776 from MiLk/fixes/git-repo-info-branch
ansible.utils._git_repo_info() now supports branch names with slashes
This commit is contained in:
commit
a61a3e28da
1 changed files with 8 additions and 4 deletions
|
@ -422,16 +422,20 @@ class CLI(object):
|
||||||
except (IOError, AttributeError):
|
except (IOError, AttributeError):
|
||||||
return ''
|
return ''
|
||||||
f = open(os.path.join(repo_path, "HEAD"))
|
f = open(os.path.join(repo_path, "HEAD"))
|
||||||
branch = f.readline().split('/')[-1].rstrip("\n")
|
line = f.readline().rstrip("\n")
|
||||||
|
if line.startswith("ref:"):
|
||||||
|
branch_path = os.path.join(repo_path, line[5:])
|
||||||
|
else:
|
||||||
|
branch_path = None
|
||||||
f.close()
|
f.close()
|
||||||
branch_path = os.path.join(repo_path, "refs", "heads", branch)
|
if branch_path and os.path.exists(branch_path):
|
||||||
if os.path.exists(branch_path):
|
branch = '/'.join(line.split('/')[2:])
|
||||||
f = open(branch_path)
|
f = open(branch_path)
|
||||||
commit = f.readline()[:10]
|
commit = f.readline()[:10]
|
||||||
f.close()
|
f.close()
|
||||||
else:
|
else:
|
||||||
# detached HEAD
|
# detached HEAD
|
||||||
commit = branch[:10]
|
commit = line[:10]
|
||||||
branch = 'detached HEAD'
|
branch = 'detached HEAD'
|
||||||
branch_path = os.path.join(repo_path, "HEAD")
|
branch_path = os.path.join(repo_path, "HEAD")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue