diff --git a/lib/ansible/modules/source_control/git.py b/lib/ansible/modules/source_control/git.py index c94d588a12..a940d6ef68 100644 --- a/lib/ansible/modules/source_control/git.py +++ b/lib/ansible/modules/source_control/git.py @@ -294,6 +294,9 @@ def head_splitter(headfile, remote, module=None, fail_on_error=False): def unfrackgitpath(path): + if path is None: + return None + # copied from ansible.utils.path return os.path.normpath(os.path.realpath(os.path.expanduser(os.path.expandvars(path)))) @@ -637,7 +640,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 == unfrackgitpath(repo): + if remote_url == repo or unfrackgitpath(remote_url) == unfrackgitpath(repo): return False command = [git_path, 'remote', 'set-url', remote, repo] @@ -1009,7 +1012,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 != unfrackgitpath(repo) + remote_url_changed = remote_url and remote_url != repo and unfrackgitpath(remote_url) != unfrackgitpath(repo) else: remote_url_changed = set_remote_url(git_path, module, repo, dest, remote) result.update(remote_url_changed=remote_url_changed) diff --git a/test/integration/targets/git/tasks/checkout-new-tag.yml b/test/integration/targets/git/tasks/checkout-new-tag.yml index d0ba656775..fded0af634 100644 --- a/test/integration/targets/git/tasks/checkout-new-tag.yml +++ b/test/integration/targets/git/tasks/checkout-new-tag.yml @@ -48,9 +48,6 @@ that: - not update_new_tag|changed - "'newtag' in listoftags.stdout_lines" - # This test fails on osx. - # Skipping it here so the remaining tests can be enabled. - when: '{{ ansible_distribution != "MacOSX" }}' - name: clear checkout_dir