-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow tree-ish versions for ansible-galaxy #13203
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,5 +310,3 @@ def spec(self): | |
} | ||
""" | ||
return dict(scm=self.scm, src=self.src, version=self.version, name=self.name) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,17 @@ def scm_archive_role(src, scm='git', name=None, version='HEAD'): | |
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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it wold be helpful to get the error from the scm, but i would worry then that the wait call might block, it would require changing the code to account for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very similar (to the extent it might be worth abstracting it) code is in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i've been meaning to fix that also, i finally let it go cause I did not have the time, i spent too much trying to restructure galaxy and roles. This is not a showstopper. |
||
|
||
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.tar') | ||
if scm == 'hg': | ||
archive_cmd = ['hg', 'archive', '--prefix', "%s/" % name] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a reason do not use a simple test?
imho, it's more zen :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach in the modification regarding testing
rc
was "adopt-and-go" with existing coding conventions. Shifting those conventions for enhanced zen may be desired, but the scope of doing so would be larger than this PR. Considering occurences in the ansible code base ofrc != 0
:Making this change may or may not be desired, if so might it best be undertaken in its own PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm fine with the less 'zenliness' of
rc != 0
as this reflects the non pythonic shelling out to a command line utility