Detect unchanged pip runs when using a vcs url in name

Should fix bug #1645
pull/18777/head
Daniele Varrazzo 9 years ago committed by Matt Clay
parent 53e1310a7f
commit a057431a78

@ -20,6 +20,7 @@
# #
import tempfile import tempfile
import re
import os import os
DOCUMENTATION = ''' DOCUMENTATION = '''
@ -321,17 +322,15 @@ def main():
# Automatically apply -e option to extra_args when source is a VCS url. VCS # Automatically apply -e option to extra_args when source is a VCS url. VCS
# includes those beginning with svn+, git+, hg+ or bzr+ # includes those beginning with svn+, git+, hg+ or bzr+
if name: has_vcs = bool(name and re.match(r'(svn|git|hg|bzr)\+', name))
if module.params['editable']: if has_vcs and module.params['editable']:
if name.startswith('svn+') or name.startswith('git+') or \ args_list = [] # used if extra_args is not used at all
name.startswith('hg+') or name.startswith('bzr+'): if extra_args:
args_list = [] # used if extra_args is not used at all args_list = extra_args.split(' ')
if extra_args: if '-e' not in args_list:
args_list = extra_args.split(' ') args_list.append('-e')
if '-e' not in args_list: # Ok, we will reconstruct the option string
args_list.append('-e') extra_args = ' '.join(args_list)
# Ok, we will reconstruct the option string
extra_args = ' '.join(args_list)
if extra_args: if extra_args:
cmd += ' %s' % extra_args cmd += ' %s' % extra_args
@ -344,8 +343,7 @@ def main():
if module.check_mode: if module.check_mode:
if extra_args or requirements or state == 'latest' or not name: if extra_args or requirements or state == 'latest' or not name:
module.exit_json(changed=True) module.exit_json(changed=True)
elif name.startswith('svn+') or name.startswith('git+') or \ elif has_vcs:
name.startswith('hg+') or name.startswith('bzr+'):
module.exit_json(changed=True) module.exit_json(changed=True)
freeze_cmd = '%s freeze' % pip freeze_cmd = '%s freeze' % pip
@ -363,7 +361,7 @@ def main():
changed = (state == 'present' and not is_present) or (state == 'absent' and is_present) changed = (state == 'present' and not is_present) or (state == 'absent' and is_present)
module.exit_json(changed=changed, cmd=freeze_cmd, stdout=out, stderr=err) module.exit_json(changed=changed, cmd=freeze_cmd, stdout=out, stderr=err)
if requirements: if requirements or has_vcs:
freeze_cmd = '%s freeze' % pip freeze_cmd = '%s freeze' % pip
out_freeze_before = module.run_command(freeze_cmd, cwd=chdir)[1] out_freeze_before = module.run_command(freeze_cmd, cwd=chdir)[1]
else: else:

Loading…
Cancel
Save