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
+3 -3
View File
@@ -66,7 +66,7 @@ def place_of(name: str, others: list[pathlib.Path], git: Git) -> str | Failure:
"""The address of the repo called name beside the others: all of them on one host and owner. An Unsure otherwise."""
if not others:
return Unsure(f"{name} is missing and no other repo of the epic shows what host to clone it from. Where does it live?")
urls: dict[str, pathlib.Path] = {}
urls = set()
for other in others:
origin = git("remote", "get-url", "origin", cwd=str(other))
if isinstance(origin, Failure):
@@ -74,9 +74,9 @@ def place_of(name: str, others: list[pathlib.Path], git: Git) -> str | Failure:
beside = url_beside(origin.strip(), name)
if beside is None:
return Unsure(f"{other} has an origin, {origin.strip()}, with no place to put another repo in. Where does {name} live?")
urls[beside] = other
urls.add(beside)
if len(urls) > 1:
return Unsure(f"The epic's other repos sit in more than one place, so {name} could be at {' or '.join(urls)}. Which holds it?")
return Unsure(f"The epic's other repos sit in more than one place, so {name} could be at {' or '.join(sorted(urls))}. Which holds it?")
url = next(iter(urls))
if not re.fullmatch(CLONE_ADDRESS, url):
return Unsure(f"{url} is not an https, ssh or scp-style address. Where does {name} live?")
+5 -5
View File
@@ -35,7 +35,7 @@ class LocateTest(unittest.TestCase):
self.addCleanup(made.cleanup)
self.home = pathlib.Path(made.name).resolve()
self.projects = self.home / ".claude-projects"
self.config = DoEpicConfig(self.projects / "do-epic", "https://acme.atlassian.net", self.home / "jira.env", self.home / "code", "English", "claude-opus-5-5", "rule")
self.config = DoEpicConfig(self.projects / "do-epic", "https://acme.atlassian.net", self.home / "jira.env", self.home / "clones", "English", "claude-opus-5-5", "rule")
self.billing, self.payments = self.home / "elsewhere" / "billing", self.home / "elsewhere" / "payments"
self.origins: dict[str, str | Failure] = {str(self.billing): "git@github.com:acme/billing.git", str(self.payments): "git@github.com:acme/payments"}
@@ -69,9 +69,9 @@ class LocateTest(unittest.TestCase):
def test_clones_into_the_clone_folder_and_asks_for_a_config_where_none_names_the_repo(self) -> None:
git = FakeGit(self.origins)
asked = self.unsure(git)
self.assertEqual(git.cloned, [("git@github.com:acme/ledger", str(self.home / "code" / "ledger"))])
self.assertIn(f"{self.projects}/<key>/config.toml", asked)
self.assertIn(f"checkout = \"{self.home / 'code' / 'ledger'}\"", asked)
clone = self.home / "clones" / "ledger"
self.assertEqual(git.cloned, [("git@github.com:acme/ledger", str(clone))])
self.assertEqual(asked, f"{clone} was cloned, but no project config names it. Write {self.projects}/<key>/config.toml with `checkout = \"{clone}\"`, as `project-config --help` shows, and run do-epic again.")
self.assertEqual(self.unsure(git), asked.replace("was cloned", "holds the repo"), "the second ask finds the clone and clones nothing")
self.assertEqual(len(git.cloned), 1)
@@ -80,7 +80,7 @@ class LocateTest(unittest.TestCase):
self.origins[str(self.payments)] = "git@gitea.larvit.se:acme/payments"
git = FakeGit(self.origins)
asked = self.unsure(git)
self.assertIn("git@github.com:acme/ledger or git@gitea.larvit.se:acme/ledger", asked)
self.assertIn("git@gitea.larvit.se:acme/ledger or git@github.com:acme/ledger", asked)
self.assertEqual(git.cloned, [])
def test_asks_where_the_other_repos_differ_only_by_owner(self) -> None: