1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

git: Use a local copy of unfrackpath to avoid using ansible.lib (#4426)

Fixes #4425
This commit is contained in:
jctanner 2016-08-15 12:22:55 -04:00 committed by Matt Clay
parent c60954605b
commit 7e65315d92

View file

@ -204,11 +204,15 @@ EXAMPLES = '''
- git: repo=https://github.com/ansible/ansible-examples.git dest=/src/ansible-examples refspec=+refs/pull/*:refs/heads/*
'''
import os
import re
import tempfile
from ansible.utils.path import unfrackpath
from distutils.version import LooseVersion
def unfrackgitpath(path):
# copied from ansible.utils.path
return os.path.normpath(os.path.realpath(os.path.expanduser(os.path.expandvars(path))))
def get_submodule_update_params(module, git_path, cwd):
#or: git submodule [--quiet] update [--init] [-N|--no-fetch]
@ -536,7 +540,7 @@ def set_remote_url(git_path, module, repo, dest, remote):
''' updates repo from remote sources '''
# Return if remote URL isn't changing.
remote_url = get_remote_url(git_path, module, dest, remote)
if remote_url == repo or remote_url == unfrackpath(repo):
if remote_url == repo or remote_url == unfrackgitpath(repo):
return False
command = [git_path, 'remote', 'set-url', remote, repo]
@ -882,7 +886,7 @@ def main():
# exit if already at desired sha version
if module.check_mode:
remote_url = get_remote_url(git_path, module, dest, remote)
remote_url_changed = remote_url and remote_url != repo and remote_url != unfrackpath(repo)
remote_url_changed = remote_url and remote_url != repo and remote_url != unfrackgitpath(repo)
else:
remote_url_changed = set_remote_url(git_path, module, repo, dest, remote)
if remote_url_changed: