Merge "fix: Support cloning URLs that end in .git"

This commit is contained in:
Zuul 2018-10-15 18:08:33 +00:00 committed by Gerrit Code Review
commit 7ef4bb78fc
2 changed files with 23 additions and 2 deletions

View File

@ -291,6 +291,8 @@ def _extract_repo_url_and_revision(repo_path_or_url):
# extract revision from repo URL or path
repo_url_or_path, revision = repo_path_or_url.rsplit('@', 1)
revision = revision[:-1] if revision.endswith('/') else revision
if revision.endswith(".git"):
revision = revision[:-4]
else:
repo_url_or_path = repo_path_or_url
except Exception:

View File

@ -101,6 +101,27 @@ class TestSiteCliActions(BaseCLIActionTest):
# are written out to sensibly named files like airship-treasuremap.yaml
assert collected_files[0] == ("%s.yaml" % self.repo_name)
def test_collect_using_remote_repo_url_ending_with_dot_git(self):
"""Validates collect action using a remote URL ending in .git."""
# Scenario:
#
# 1) Create temporary save location
# 2) Collect into save location (should clone repo automatically)
# 3) Check that expected file name is there
save_location = tempfile.mkdtemp()
repo_url = 'https://github.com/openstack/%s@%s.git' % (self.repo_name,
self.repo_rev)
result = self.runner.invoke(
cli.site,
['-r', repo_url, 'collect', self.site_name, '-s', save_location])
collected_files = os.listdir(save_location)
assert result.exit_code == 0
assert len(collected_files) == 1
assert collected_files[0] == ("%s.yaml" % self.repo_name)
def test_collect_using_local_path(self):
"""Validates collect action using a path to a local repo."""
# Scenario:
@ -120,8 +141,6 @@ class TestSiteCliActions(BaseCLIActionTest):
assert result.exit_code == 0
assert len(collected_files) == 1
# Validates that site manifests collected from cloned repositories
# are written out to sensibly named files like airship-treasuremap.yaml
assert collected_files[0] == ("%s.yaml" % self.repo_name)
### Lint tests ###