Skip to content
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"),
[
"git@github.com: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"