Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions howfairis/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _derive_api(self):
if self.platform == Platform.GITHUB:
api = f"https://api.github.com/repos/{self.owner}/{self.repo}"
elif self.platform == Platform.GITLAB:
api = f"https://gitlab.com/api/v4/projects/{self.owner}%2F{self.repo}"
api = f"https://gitlab.com/api/v4/projects/{self.owner.replace('/','%2F')}%2F{self.repo}"
return api

def _derive_reuse_url(self):
Expand All @@ -88,9 +88,8 @@ def _derive_owner_and_repo(self):

elif self.platform == Platform.GITLAB:
try:
owner, repo = (
self.url.replace("https://gitlab.com", "").strip("/").split("/")[:2]
)
owner = '/'.join(self.url.replace("https://gitlab.com", "").strip("/").split("/")[0:-1])
repo = self.url.replace("https://gitlab.com", "").strip("/").split("/")[-1:][0]
except ValueError as ex:
raise ValueError("Bad value for input argument URL.") from ex

Expand Down
9 changes: 9 additions & 0 deletions livetests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ def test_valid_gitlab_url_unauthenticated():
assert actual_exit_code == expected_exit_code


def test_valid_gitlab_group_url_unauthenticated():
assert os.getenv("APIKEY_GITLAB") is None, "This test should run unauthenticated"
runner = CliRunner()
result = runner.invoke(cli, ["https://gitlab.com/hifis/hifis-workshops/make-your-code-ready-for-publication/astronaut-analysis"])
assert (
"url: https://gitlab.com/hifis/hifis-workshops/make-your-code-ready-for-publication/astronaut-analysis\n(1/5) repository" in result.stdout
), "Did not find expected string"


def test_invalid_url():
runner = CliRunner()
result = runner.invoke(cli, ["howfairis"])
Expand Down