mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Corrected bug where role_path was wrong for roles in subdirectories
Fixed role name for - { role: 'lives/in/a/subdirectory' } Should be 'lives/in/a/subdirectory', not just 'subdirectory'
This commit is contained in:
parent
bf9ea81c4b
commit
6e9abefc11
2 changed files with 8 additions and 5 deletions
|
@ -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]
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue