feat(mirror,create): make MIRRORS single source of truth and exclude PyPI from git config
Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / lint-shell (push) Has been cancelled
Mark stable commit / lint-python (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled

- Treat MIRRORS as the only authority for mirror URLs
- Filter non-git URLs (e.g. PyPI) from git remotes and push URLs
- Prefer SSH git URLs when determining primary origin
- Ensure mirror probing only targets valid git remotes
- Refactor repository create into service-based architecture
- Write PyPI metadata exclusively to MIRRORS, never to git config
- Add integration test verifying PyPI is not written into .git/config
- Update preview and unit tests to match new create flow

https://chatgpt.com/share/69415c61-1c5c-800f-86dd-0405edec25db
This commit is contained in:
Kevin Veen-Birkenbach
2025-12-16 14:19:19 +01:00
parent 374f4ed745
commit 8583fdf172
19 changed files with 792 additions and 418 deletions

View File

@@ -15,17 +15,47 @@ class TestCreateRepoPreviewOutput(unittest.TestCase):
out = io.StringIO()
with (
redirect_stdout(out),
patch("pkgmgr.actions.repository.create.os.path.exists", return_value=False),
patch("pkgmgr.actions.repository.create.generate_alias", return_value="repo"),
patch("pkgmgr.actions.repository.create.save_user_config"),
patch("pkgmgr.actions.repository.create.os.makedirs"),
patch("pkgmgr.actions.repository.create.render_default_templates"),
patch("pkgmgr.actions.repository.create.write_mirrors_file"),
patch("pkgmgr.actions.repository.create.setup_mirrors"),
patch("pkgmgr.actions.repository.create.get_config_value", return_value=None),
patch("pkgmgr.actions.repository.create.init"),
patch("pkgmgr.actions.repository.create.add_all"),
patch("pkgmgr.actions.repository.create.commit"),
patch(
"pkgmgr.actions.repository.create.config_writer.generate_alias",
return_value="repo",
),
patch(
"pkgmgr.actions.repository.create.config_writer.save_user_config",
),
patch(
"pkgmgr.actions.repository.create.config_writer.os.path.exists",
return_value=False,
),
patch(
"pkgmgr.actions.repository.create.service.os.makedirs",
),
patch(
"pkgmgr.actions.repository.create.templates.TemplateRenderer._resolve_templates_dir",
return_value="/tpl",
),
patch(
"pkgmgr.actions.repository.create.templates.os.walk",
return_value=[("/tpl", [], ["README.md.j2"])],
),
patch(
"pkgmgr.actions.repository.create.git_bootstrap.init",
),
patch(
"pkgmgr.actions.repository.create.git_bootstrap.add_all",
),
patch(
"pkgmgr.actions.repository.create.git_bootstrap.commit",
),
patch(
"pkgmgr.actions.repository.create.mirrors.write_mirrors_file",
),
patch(
"pkgmgr.actions.repository.create.mirrors.setup_mirrors",
),
patch(
"pkgmgr.actions.repository.create.service.get_config_value",
return_value=None,
),
):
create_repo(
"github.com/acme/repo",
@@ -37,7 +67,7 @@ class TestCreateRepoPreviewOutput(unittest.TestCase):
)
s = out.getvalue()
self.assertIn("[Preview] Would save user config:", s)
self.assertIn("[Preview] Would add repository to config:", s)
self.assertIn("[Preview] Would ensure directory exists:", s)