summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2016-02-17 08:41:29 -0500
committerJames Cammarata <jimi@sngx.net>2016-02-17 08:41:29 -0500
commit58a6cf822a1352ff06920a372201874727c7da28 (patch)
tree7ad06eab1f2edde38235f8a34768e7364279288b /lib
parent875ea74621fab45e8d8ee07bcc72ba65c568a069 (diff)
parentff19233ad33dc989e997e69b4f36cab56fae74da (diff)
downloadansible-58a6cf822a1352ff06920a372201874727c7da28.tar.gz
Merge pull request #13203 from willthames/galaxy_10620
Allow tree-ish versions for ansible-galaxy
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/galaxy/role.py2
-rw-r--r--lib/ansible/playbook/role/requirement.py11
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/ansible/galaxy/role.py b/lib/ansible/galaxy/role.py
index 700664c4cd..5472255480 100644
--- a/lib/ansible/galaxy/role.py
+++ b/lib/ansible/galaxy/role.py
@@ -310,5 +310,3 @@ class GalaxyRole(object):
}
"""
return dict(scm=self.scm, src=self.src, version=self.version, name=self.name)
-
-
diff --git a/lib/ansible/playbook/role/requirement.py b/lib/ansible/playbook/role/requirement.py
index 1a640247e2..807dd1e82f 100644
--- a/lib/ansible/playbook/role/requirement.py
+++ b/lib/ansible/playbook/role/requirement.py
@@ -190,6 +190,17 @@ class RoleRequirement(RoleDefinition):
if rc != 0:
raise AnsibleError ("- command %s failed in directory %s (rc=%s)" % (' '.join(clone_cmd), tempdir, rc))
+ if scm == 'git' and version:
+ checkout_cmd = [scm, 'checkout', version]
+ with open('/dev/null', 'w') as devnull:
+ try:
+ popen = subprocess.Popen(checkout_cmd, cwd=os.path.join(tempdir, name), stdout=devnull, stderr=devnull)
+ except (IOError, OSError):
+ raise AnsibleError("error executing: %s" % " ".join(checkout_cmd))
+ rc = popen.wait()
+ if rc != 0:
+ raise AnsibleError("- command %s failed in directory %s (rc=%s)" % (' '.join(checkout_cmd), tempdir, rc))
+
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.tar')
if scm == 'hg':
archive_cmd = ['hg', 'archive', '--prefix', "%s/" % name]