Kill the surviving mutants of repos.py and url_beside

This commit is contained in:
2026-11-18 13:06:55 +01:00
parent 3de693f1a5
commit 2776d1694d
4 changed files with 13 additions and 13 deletions
+4 -5
View File
@@ -18,11 +18,10 @@ def forge_of(origin_url: str) -> Forge:
def url_beside(origin_url: str, name: str) -> str | None:
"""The origin URL of the repo called name in the same place, host and owner, as origin_url's repo; None where origin_url has no place, such as a bare name. A trailing `.git` is dropped, since gh and tea clone without it."""
trimmed = origin_url.rstrip("/").removesuffix(".git")
place = re.fullmatch(r"(.+[/:])[^/:]+", trimmed)
# A scheme's own `//` or `:` leaves no repo to put a name beside.
return place.group(1) + name if place and not place.group(1).endswith("//") and not re.fullmatch(r"\w+:", place.group(1)) else None
"""The origin URL of the repo called name in the same place, host and owner, as origin_url's repo; None where origin_url has no place, such as a bare name. The URL has no `.git`, since gh and tea clone without it."""
place = re.fullmatch(r"(.+[/:])[^/:]+", origin_url.rstrip("/"))
# A scheme's own `//` leaves no repo to put a name beside.
return place.group(1) + name if place and not place.group(1).endswith("//") else None
def runner(cwd: str) -> Run:
+1
View File
@@ -21,6 +21,7 @@ class UrlBeside(unittest.TestCase):
self.assertEqual(url_beside("git@github.com:acme/billing.git", "ledger"), "git@github.com:acme/ledger")
self.assertEqual(url_beside("https://gitea.larvit.se/acme/billing", "ledger"), "https://gitea.larvit.se/acme/ledger")
self.assertEqual(url_beside("https://gitea.larvit.se/acme/billing.git/", "ledger"), "https://gitea.larvit.se/acme/ledger")
self.assertEqual(url_beside("gitea:billing", "ledger"), "gitea:ledger", "a host with no owner")
def test_names_none_where_the_origin_has_no_place_to_put_a_repo_in(self):
self.assertIsNone(url_beside("billing", "ledger"))