Skip to content

Commit ddac47c

Browse files
committed
handle trailing slash in git url
fixes #7326
1 parent 9b3893a commit ddac47c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/poetry/vcs/git/backend.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def info(cls, repo: Repo | Path) -> GitRepoLocalInfo:
184184

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

189189
@classmethod
190190
def _fetch_remote_refs(cls, url: str, local: Repo) -> FetchPackResult:

tests/vcs/git/test_backend.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from __future__ import annotations
22

3+
import pytest
4+
5+
from poetry.vcs.git.backend import Git
36
from poetry.vcs.git.backend import is_revision_sha
47

58

@@ -24,3 +27,17 @@ def test_invalid_revision_sha_min_len() -> None:
2427
def test_invalid_revision_sha_max_len() -> None:
2528
result = is_revision_sha(VALID_SHA + "42")
2629
assert result is False
30+
31+
32+
@pytest.mark.parametrize(
33+
("url"),
34+
[
35+
"[email protected]:poetry-core/poetry.git",
36+
"https://github.com/poetry-core/poetry.git",
37+
"https://github.com/poetry-core/poetry",
38+
"https://github.com/poetry-core/poetry/",
39+
],
40+
)
41+
def test_get_name_from_source_url(url: str) -> None:
42+
name = Git.get_name_from_source_url(url)
43+
assert name == "poetry"

0 commit comments

Comments
 (0)