From db0c5d4ec8dfc82c2c430d5e6e5d7ff69c72b99e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 18 Nov 2026 13:24:50 +0100 Subject: [PATCH] Strip credentials up to the last @ before the path --- bin/do_epic/repos.py | 2 +- bin/do_epic/test_repos.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/do_epic/repos.py b/bin/do_epic/repos.py index 922489ea..b9666b3d 100644 --- a/bin/do_epic/repos.py +++ b/bin/do_epic/repos.py @@ -67,7 +67,7 @@ def ensure(name: str, checkout: pathlib.Path, others: list[pathlib.Path], git: G def without_credentials(url: str) -> str: """url without a `user:token@` after its scheme, so that a clone and a question for the team never carry one. The clone then uses git's own credentials.""" - return re.sub(r"^(https?://)[^/@]*@", r"\1", url) + return re.sub(r"^(https?://)[^/]*@", r"\1", url) def clone_url(name: str, others: list[pathlib.Path], git: Git) -> str | Failure: diff --git a/bin/do_epic/test_repos.py b/bin/do_epic/test_repos.py index 72acf675..bcf2ef88 100644 --- a/bin/do_epic/test_repos.py +++ b/bin/do_epic/test_repos.py @@ -137,11 +137,11 @@ class LocateTest(unittest.TestCase): def test_clones_and_asks_without_the_credentials_an_origin_holds(self) -> None: self.configure() self.origins[str(self.billing)] = "https://bot:s3cret@gitea.larvit.se/acme/billing" - self.origins[str(self.payments)] = "https://other:t0ken@gitea.larvit.se/acme/payments.git" + self.origins[str(self.payments)] = "https://other:t0@ken@gitea.larvit.se/acme/payments.git" git = FakeGit(self.origins) self.assertIsInstance(self.locate(git), Located) self.assertEqual(git.cloned, [("https://gitea.larvit.se/acme/ledger", str(self.home / "code" / "ledger"))]) - self.origins[str(self.payments)] = "https://other:t0ken@gitea.larvit.se/acme/payments" + self.origins[str(self.payments)] = "https://other:t0@ken@gitea.larvit.se/acme/payments" self.origins[str(self.billing)] = "https://bot:s3cret@gitea.larvit.se" self.assertNotIn("s3cret", self.unsure(FakeGit(self.origins), "stock"))