gitweb: Remove invalid use of str.rstrip
rstrip is not a method to remove a string suffix so use another way to extract gitweb project name. It fixes the computation of some gitweb origin URLs. Related to swh/infra/sysadm-environment#5050.
This commit is contained in:
parent
aa7b3fa7d8
commit
a04975571c
2 changed files with 7 additions and 7 deletions
|
@ -167,13 +167,9 @@ def try_to_determine_git_repository(repository_url: str) -> Optional[str]:
|
|||
"""
|
||||
result = None
|
||||
parsed_url = urlparse(repository_url)
|
||||
params = parse_qs(parsed_url.query).get("p")
|
||||
if params:
|
||||
repo = params[0]
|
||||
if repo and repo.endswith(";a=summary"):
|
||||
repo = repo.rstrip(";a=summary")
|
||||
|
||||
result = f"git://{parsed_url.netloc}/{repo}"
|
||||
repo = parse_qs(parsed_url.query, separator=";").get("p")
|
||||
if repo:
|
||||
result = f"git://{parsed_url.netloc}/{repo[0]}"
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
@ -138,6 +138,10 @@ def test_lister_gitweb_get_origin_from_repo_failing(
|
|||
"https://git.shadowcat.co.uk?p=File-Slurp.git;a=summary",
|
||||
"git://git.shadowcat.co.uk/File-Slurp.git",
|
||||
),
|
||||
(
|
||||
"https://git.example.org?p=baaaa;a=summary",
|
||||
"git://git.example.org/baaaa",
|
||||
),
|
||||
("https://domain.org/foobar", None),
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue