diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 5692d6986bc..3211a62ec6b 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -353,6 +353,8 @@ def path_dwim_relative(original, dirname, source, playbook_base, check=True): return source2 # which does not exist def repo_url_to_role_name(repo_url): + if '://' not in repo_url: + return repo_url trailing_path = repo_url.split('/')[-1] if trailing_path.endswith('.git'): trailing_path = trailing_path[:-4] diff --git a/test/units/TestUtils.py b/test/units/TestUtils.py index 0c7bc4c4c90..f7409070406 100644 --- a/test/units/TestUtils.py +++ b/test/units/TestUtils.py @@ -781,15 +781,16 @@ class TestUtils(unittest.TestCase): def test_repo_url_to_role_name(self): tests = [("http://git.example.com/repos/repo.git", "repo"), ("ssh://git@git.example.com:repos/role-name", "role-name"), - ("ssh://git@git.example.com:repos/role-name,v0.1", "role-name")] + ("ssh://git@git.example.com:repos/role-name,v0.1", "role-name"), + ("directory/role/is/installed/in", "directory/role/is/installed/in")] for (url, result) in tests: self.assertEqual(ansible.utils.repo_url_to_role_name(url), result) def test_role_spec_parse(self): - tests = [("git+http://git.example.com/repos/repo.git,v1.0", ('git', 'http://git.example.com/repos/repo.git', 'v1.0', 'repo')), - ("http://repo.example.com/download/tarfile.tar.gz", (None, 'http://repo.example.com/download/tarfile.tar.gz', '', 'tarfile')), - ("http://repo.example.com/download/tarfile.tar.gz,,nicename", (None, 'http://repo.example.com/download/tarfile.tar.gz', '', 'nicename')), - ("git+http://git.example.com/repos/repo.git,v1.0,awesome", ('git', 'http://git.example.com/repos/repo.git', 'v1.0', 'awesome'))] + tests = [("git+http://git.example.com/repos/repo.git,v1.0", {'scm': 'git', 'src': 'http://git.example.com/repos/repo.git', 'version': 'v1.0', 'name': 'repo'}), + ("http://repo.example.com/download/tarfile.tar.gz", {'scm': None, 'src': 'http://repo.example.com/download/tarfile.tar.gz', 'version': '', 'name': 'tarfile'}), + ("http://repo.example.com/download/tarfile.tar.gz,,nicename", {'scm': None, 'src': 'http://repo.example.com/download/tarfile.tar.gz', 'version': '', 'name': 'nicename'}), + ("git+http://git.example.com/repos/repo.git,v1.0,awesome", {'scm': 'git', 'src': 'http://git.example.com/repos/repo.git', 'version': 'v1.0', 'name': 'awesome'})] for (spec, result) in tests: self.assertEqual(ansible.utils.role_spec_parse(spec), result)