Merge "fix: Support cloning URLs that end in .git"
This commit is contained in:
commit
7ef4bb78fc
@ -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:
|
||||
|
@ -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 ###
|
||||
|
Loading…
Reference in New Issue
Block a user