From 4803e923fff3a84389b9b1e5462badecdacb770d Mon Sep 17 00:00:00 2001 From: Will Thames Date: Thu, 14 Aug 2014 20:48:25 +1000 Subject: [PATCH] Improved handling of role_version in repo_url_to_role_name --- lib/ansible/utils/__init__.py | 2 ++ test/units/TestUtils.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 9c9dcadda7..af2bfa1919 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -356,6 +356,8 @@ def repo_url_to_role_name(repo_url): trailing_path = repo_url.split('/')[-1] if trailing_path.endswith('.git'): trailing_path = trailing_path[:-4] + if ',' in trailing_path: + trailing_path = trailing_path.split(',')[0] return trailing_path def json_loads(data): diff --git a/test/units/TestUtils.py b/test/units/TestUtils.py index ca4cbc07db..8593ca3de2 100644 --- a/test/units/TestUtils.py +++ b/test/units/TestUtils.py @@ -780,6 +780,7 @@ 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", "role-name"), + ("ssh://git@git.example.com:repos/role-name,v0.1", "role-name")] for (url, result) in tests: self.assertEqual(ansible.utils.repo_url_to_role_name(url), result)