Files
pkgmgr/tests/e2e/test_mirror_commands.py

165 lines
4.6 KiB
Python
Raw Normal View History

Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
E2E integration tests for the `pkgmgr mirror` command family.
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
Covered commands:
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
- pkgmgr mirror --help
- pkgmgr mirror list --preview --all
- pkgmgr mirror diff --preview --all
- pkgmgr mirror merge config file --preview --all
- pkgmgr mirror setup --preview --all
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
- pkgmgr mirror check --preview --all
- pkgmgr mirror provision --preview --all
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
All commands are executed via the real CLI entry point (main module).
With --preview enabled, all operations are non-destructive and safe
to run inside CI containers.
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
import io
import runpy
import sys
import unittest
from contextlib import redirect_stdout, redirect_stderr
class TestIntegrationMirrorCommands(unittest.TestCase):
"""
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
End-to-end tests for `pkgmgr mirror` commands.
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
# ------------------------------------------------------------
# Helper
# ------------------------------------------------------------
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
def _run_pkgmgr(self, args):
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
Execute pkgmgr with the given arguments and return captured output.
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
- Treat SystemExit(0) or SystemExit(None) as success.
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
- Any other exit code is considered a test failure.
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
original_argv = list(sys.argv)
buffer = io.StringIO()
cmd_repr = "pkgmgr " + " ".join(args)
try:
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
sys.argv = ["pkgmgr"] + list(args)
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
try:
with redirect_stdout(buffer), redirect_stderr(buffer):
runpy.run_module("pkgmgr", run_name="__main__")
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
except SystemExit as exc:
code = exc.code if isinstance(exc.code, int) else None
if code not in (0, None):
raise AssertionError(
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
"%r failed with exit code %r.\n\nOutput:\n%s"
% (cmd_repr, exc.code, buffer.getvalue())
)
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
return buffer.getvalue()
finally:
sys.argv = original_argv
# ------------------------------------------------------------
# Tests
# ------------------------------------------------------------
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
def test_mirror_help(self):
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
`pkgmgr mirror --help` should run without error and print usage info.
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
output = self._run_pkgmgr(["mirror", "--help"])
self.assertIn("usage:", output)
self.assertIn("pkgmgr mirror", output)
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
def test_mirror_list_preview_all(self):
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
`pkgmgr mirror list --preview --all`
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
output = self._run_pkgmgr(
["mirror", "list", "--preview", "--all"]
)
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
self.assertTrue(
output.strip(),
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
"Expected output from mirror list",
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
)
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
def test_mirror_diff_preview_all(self):
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
`pkgmgr mirror diff --preview --all`
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
output = self._run_pkgmgr(
["mirror", "diff", "--preview", "--all"]
)
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
self.assertTrue(
output.strip(),
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
"Expected output from mirror diff",
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
)
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
def test_mirror_merge_config_to_file_preview_all(self):
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
`pkgmgr mirror merge config file --preview --all`
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
output = self._run_pkgmgr(
[
"mirror",
"merge",
"config",
"file",
"--preview",
"--all",
]
)
self.assertTrue(
output.strip(),
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
"Expected output from mirror merge (config -> file)",
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
)
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
def test_mirror_setup_preview_all(self):
"""
`pkgmgr mirror setup --preview --all`
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
output = self._run_pkgmgr(
["mirror", "setup", "--preview", "--all"]
)
self.assertTrue(
output.strip(),
"Expected output from mirror setup",
)
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
def test_mirror_check_preview_all(self):
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
"""
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
`pkgmgr mirror check --preview --all`
Performs non-destructive remote checks (git ls-remote).
"""
output = self._run_pkgmgr(
["mirror", "check", "--preview", "--all"]
)
self.assertTrue(
output.strip(),
"Expected output from mirror check",
)
def test_mirror_provision_preview_all(self):
"""
`pkgmgr mirror provision --preview --all`
In preview mode this MUST NOT create remote repositories.
"""
output = self._run_pkgmgr(
["mirror", "provision", "--preview", "--all"]
)
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
self.assertTrue(
output.strip(),
* **Split mirror responsibilities into clear subcommands** Setup configures local Git state, check validates remote reachability in a read-only way, and provision explicitly creates missing remote repositories. Destructive behavior is never implicit. * **Introduce a remote provisioning layer** pkgmgr can now ensure that repositories exist on remote providers. If a repository is missing, it can be created automatically on supported platforms when explicitly requested. * **Add a provider registry for extensibility** Providers are resolved based on the remote host, with optional hints to force a specific backend. This makes it straightforward to add further providers later without changing the core logic. * **Use a lightweight, dependency-free HTTP client** All API communication is handled via a small stdlib-based client. HTTP errors are mapped to meaningful domain errors, improving diagnostics and error handling consistency. * **Centralize credential resolution** API tokens are resolved in a strict order: environment variables first, then the system keyring, and finally an interactive prompt if allowed. This works well for both CI and interactive use. * **Keep keyring integration optional** Secure token storage via the OS keyring is provided as an optional dependency. If unavailable, pkgmgr still works using environment variables or one-off interactive tokens. * **Improve CLI parser safety and clarity** Shared argument helpers now guard against duplicate definitions, making composed subcommands more robust and easier to maintain. * **Expand end-to-end test coverage** All mirror-related workflows are exercised through real CLI invocations in preview mode, ensuring full wiring correctness while remaining safe for automated test environments. https://chatgpt.com/share/693df441-a780-800f-bcf7-96e06cc9e421
2025-12-14 00:16:54 +01:00
"Expected output from mirror provision (preview)",
Add mirror management commands and refactor CLI parser into modules - Implement new mirror actions: - list_mirrors: show mirrors from config, MIRRORS file, or merged view - diff_mirrors: compare config mirrors with MIRRORS file (ONLY IN CONFIG, ONLY IN FILE, URL MISMATCH, OK) - merge_mirrors: merge mirrors between config and MIRRORS file in both directions, with preview mode and user config writing via save_user_config - setup_mirrors: prepare local Git remotes (ensure origin) and print provider-URL suggestions for remote repositories - Introduce mirror utilities: - RepoMirrorContext with resolved_mirrors (config + file, file wins) - load_config_mirrors supporting dict and list-of-dicts shapes - read/write MIRRORS file with simple "name url" format and preview mode - helper for building default SSH URLs from provider/account/repository - Wire mirror commands into CLI: - Add handle_mirror_command and integrate "mirror" into dispatch - Add dedicated CLI parser modules under pkgmgr.cli.parser: * common, install_update, config_cmd, navigation_cmd, branch_cmd, release_cmd, version_cmd, changelog_cmd, list_cmd, make_cmd, mirror_cmd - Replace old flat cli/parser.py with modular parser package and SortedSubParsersAction in common.py - Update TODO.md to mark MIRROR as implemented - Add E2E tests for mirror commands: - test_mirror_help - test_mirror_list_preview_all - test_mirror_diff_preview_all - test_mirror_merge_config_to_file_preview_all - test_mirror_setup_preview_all https://chatgpt.com/share/693adee0-aa3c-800f-b72a-98473fdaf760
2025-12-11 16:10:19 +01:00
)
if __name__ == "__main__":
unittest.main()