cgit: remove the repository urls's trailing /

Ensure the behavior is the same when a base url is provided or not

Related to T3013#57810
This commit is contained in:
Vincent SELLIER 2021-02-01 17:31:08 +01:00
parent 003cf5491f
commit 8e4dd178f1
No known key found for this signature in database
GPG key ID: 3F13C434EADAD17D
2 changed files with 5 additions and 7 deletions

View file

@ -102,7 +102,7 @@ class CGitLister(StatelessLister[Repositories]):
repo_url = None
git_url = None
base_url = urljoin(self.url, repository_link)
base_url = urljoin(self.url, repository_link).strip("/")
if self.base_git_url: # mapping provided
# computing git url
git_url = base_url.replace(self.url, self.base_git_url)

View file

@ -21,15 +21,13 @@ def test_lister_cgit_get_pages_one_page(requests_mock_datadir, swh_scheduler):
flattened_repos = sum(repos, [])
assert len(flattened_repos) == 977
assert (
flattened_repos[0]["url"] == "https://git.savannah.gnu.org/cgit/elisp-es.git/"
)
assert flattened_repos[0]["url"] == "https://git.savannah.gnu.org/cgit/elisp-es.git"
# note the url below is NOT a subpath of /cgit/
assert (
flattened_repos[-1]["url"] == "https://git.savannah.gnu.org/path/to/yetris.git/"
flattened_repos[-1]["url"] == "https://git.savannah.gnu.org/path/to/yetris.git"
) # noqa
# note the url below is NOT on the same server
assert flattened_repos[-2]["url"] == "http://example.org/cgit/xstarcastle.git/"
assert flattened_repos[-2]["url"] == "http://example.org/cgit/xstarcastle.git"
def test_lister_cgit_get_pages_with_pages(requests_mock_datadir, swh_scheduler):
@ -146,7 +144,7 @@ def test_lister_cgit_date_parsing(date_str, expected_date):
requests_mock_datadir_missing_url = requests_mock_datadir_factory(
ignore_urls=["https://git.tizen/cgit/adaptation/ap_samsung/audio-hal-e4x12/",]
ignore_urls=["https://git.tizen/cgit/adaptation/ap_samsung/audio-hal-e4x12",]
)