Merge pull request #158 from ajsalminen/git_dereference_annotated_tag
[git] Find the actual commit annotated tags refer to instead of the tag object.
This commit is contained in:
commit
f87afc090c
1 changed files with 13 additions and 1 deletions
|
@ -320,6 +320,7 @@ def reset(git_path, module, dest):
|
|||
def get_remote_head(git_path, module, dest, version, remote, bare):
|
||||
cloning = False
|
||||
cwd = None
|
||||
tag = False
|
||||
if remote == module.params['repo']:
|
||||
cloning = True
|
||||
else:
|
||||
|
@ -334,7 +335,8 @@ def get_remote_head(git_path, module, dest, version, remote, bare):
|
|||
elif is_remote_branch(git_path, module, dest, remote, version):
|
||||
cmd = '%s ls-remote %s -h refs/heads/%s' % (git_path, remote, version)
|
||||
elif is_remote_tag(git_path, module, dest, remote, version):
|
||||
cmd = '%s ls-remote %s -t refs/tags/%s' % (git_path, remote, version)
|
||||
tag = True
|
||||
cmd = '%s ls-remote %s -t refs/tags/%s*' % (git_path, remote, version)
|
||||
else:
|
||||
# appears to be a sha1. return as-is since it appears
|
||||
# cannot check for a specific sha1 on remote
|
||||
|
@ -342,6 +344,16 @@ def get_remote_head(git_path, module, dest, version, remote, bare):
|
|||
(rc, out, err) = module.run_command(cmd, check_rc=True, cwd=cwd)
|
||||
if len(out) < 1:
|
||||
module.fail_json(msg="Could not determine remote revision for %s" % version)
|
||||
|
||||
if tag:
|
||||
# Find the dereferenced tag if this is an annotated tag.
|
||||
for tag in out.split('\n'):
|
||||
if tag.endswith(version + '^{}'):
|
||||
out = tag
|
||||
break
|
||||
elif tag.endswith(version):
|
||||
out = tag
|
||||
|
||||
rev = out.split()[0]
|
||||
return rev
|
||||
|
||||
|
|
Loading…
Reference in a new issue