Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle trailing slash in git url #9205

Merged
merged 1 commit into from
Mar 23, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/poetry/vcs/git/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def info(cls, repo: Repo | Path) -> GitRepoLocalInfo:

@staticmethod
def get_name_from_source_url(url: str) -> str:
return re.sub(r"(.git)?$", "", url.rsplit("/", 1)[-1])
return re.sub(r"(.git)?$", "", url.rstrip("/").rsplit("/", 1)[-1])

@classmethod
def _fetch_remote_refs(cls, url: str, local: Repo) -> FetchPackResult:
Expand Down
17 changes: 17 additions & 0 deletions tests/vcs/git/test_backend.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import annotations

import pytest

from poetry.vcs.git.backend import Git
from poetry.vcs.git.backend import is_revision_sha


Expand All @@ -24,3 +27,17 @@ def test_invalid_revision_sha_min_len() -> None:
def test_invalid_revision_sha_max_len() -> None:
result = is_revision_sha(VALID_SHA + "42")
assert result is False


@pytest.mark.parametrize(
("url"),
[
"[email protected]:python-poetry/poetry.git",
"https://github.com/python-poetry/poetry.git",
"https://github.com/python-poetry/poetry",
"https://github.com/python-poetry/poetry/",
],
)
def test_get_name_from_source_url(url: str) -> None:
name = Git.get_name_from_source_url(url)
assert name == "poetry"
Loading