Strip credentials up to the last @ before the path
CI / tests (pull_request) Failing after 3m42s

This commit is contained in:
2026-11-18 13:24:50 +01:00
parent 9bdf861087
commit db0c5d4ec8
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -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:
+2 -2
View File
@@ -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"))