Skip to content
Snippets Groups Projects
Commit a0497557 authored by Antoine Lambert's avatar Antoine Lambert
Browse files

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.
parent aa7b3fa7
No related branches found
No related tags found
1 merge request!504gitweb: Remove invalid use of str.rstrip
Pipeline #4413 passed
......@@ -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),
],
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment