fix: Support cloning URLs that end in .git
This patch set adds support for passing in URLs ending in .git via the --site-repository (-r) flag, e.g.: pegleg site -r https://github.com/openstack/project.git@foo [...] Unit test added to validate behavior. Change-Id: If822ed195f07dc25e0590e42d046730632fdaafd
This commit is contained in:
parent
b95853a1a7
commit
f71c2e38f8
|
@ -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:
|
||||
|
|
|
@ -82,6 +82,27 @@ class TestSiteCliActions(object):
|
|||
# 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:
|
||||
|
@ -101,6 +122,4 @@ class TestSiteCliActions(object):
|
|||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue