-
Notifications
You must be signed in to change notification settings - Fork 14
New commands: add
and add-from-fs
#465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis pull request introduces two new CLI subcommands, File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
add
and add-from-fs
add
and add-from-fs
a36fbef
to
69a222e
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #465 +/- ##
==========================================
- Coverage 78.93% 77.01% -1.93%
==========================================
Files 8 11 +3
Lines 413 770 +357
Branches 85 174 +89
==========================================
+ Hits 326 593 +267
- Misses 52 114 +62
- Partials 35 63 +28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d37cb7e
to
628830e
Compare
e85482d
to
e26036d
Compare
740c98c
to
1045626
Compare
b02d442
to
27d3297
Compare
429bca8
to
f310106
Compare
why: Need consistent YAML writing functionality for new CLI commands what: - Add save_config_yaml function to centralize config file writing - Use ConfigReader._dump for consistent formatting refs: Foundation for add/add-from-fs commands
why: Users need a way to manually add individual repositories to config what: - Add command to add single repository by name and URL - Support custom base directory with --dir option - Support path inference with --path option - Check for duplicates and warn appropriately - Use verbose format {"repo": "url"} for new entries
…ition why: Users with many existing repos need efficient bulk import what: - Scan directories for git repositories - Extract origin URLs from git config - Support recursive scanning with -r/--recursive - Custom base directory key with --base-dir-key - Auto-confirm with -y/--yes - Show summary for large numbers of existing repos
why: Sync function needs to handle cases where config is not specified what: - Change sync function signature to accept optional config - Update CLI handler to properly pass config parameter
why: CLI commands need user-friendly output without log prefixes what: - Add SimpleLogFormatter class for message-only output - Configure CLI modules (add, add_from_fs, sync) to use simple formatter - Maintain debug formatter for core vcspull logger - Set propagate=False to prevent duplicate logging
why: Ensure add command functionality is properly tested what: - Test simple repository addition - Test custom base directory handling - Test duplicate detection - Test adding to existing config
…canner why: Ensure add-from-fs functionality works correctly what: - Test git origin URL extraction - Test single and multiple repo discovery - Test recursive and non-recursive scanning - Test user confirmation flow - Test existing repo handling - Test output formatting for many repos
why: Ensure logging infrastructure works as expected what: - Test SimpleLogFormatter output - Test RepoLogFormatter functionality - Test DebugLogFormatter with various log levels - Test logger configuration and propagation
why: Some CLI output goes to stderr and was being missed what: - Capture both stdout and stderr in test_sync_cli_filter_non_existent - Ensures complete output validation in test
why: Tests didn't follow established vcspull testing patterns what: - Convert to parameterized tests using AddRepoFixture(NamedTuple) - Test through CLI entry point instead of direct function calls - Add clear_logging_handlers fixture to prevent stream closure issues - Remove caplog.set_level() calls that were causing handler conflicts - Maintain full test coverage with improved organization refs: #tests
…entions why: Tests didn't follow established vcspull testing patterns and had logging issues what: - Convert to parameterized tests using AddFromFsFixture(NamedTuple) - Test through CLI entry point for integration testing - Add helper functions setup_git_repo() and clone_repo() for test setup - Add clear_logging_handlers fixture to prevent stream closure issues - Remove caplog.set_level() calls that were causing handler conflicts - Improve test organization and maintain full coverage refs: #tests
…ception handler why: Match established error handling patterns in the codebase what: - Change raise to return in save_config_yaml exception handler - Maintains consistency with other modules' error handling approach
…se in exception handler why: Match established error handling patterns in the codebase what: - Change raise to return in save_config_yaml exception handler - Maintains consistency with other modules' error handling approach
why: Address ruff linting warnings to improve code quality and consistency what: - Move traceback imports to module level instead of conditional imports - Convert f-string logging to % formatting for better performance - Fix line length issues to meet 88 character limit - Maintain all functionality while improving code style All tests passing after changes.
why: Follow imperative mood convention for docstrings (D401) what: - Change "Helper to set up" to "Set up" in setup_git_repo docstring - Change "Helper to clone" to "Clone" in clone_repo docstring refs: D401 ruff rule
why: Users need a way to standardize and clean up their vcspull configurations what: - Add format_config_file function to format vcspull configs - Implement normalize_repo_config to convert compact to verbose format - Convert url keys to repo keys for consistency - Sort directories and repositories alphabetically - Add --write flag requirement for actual file modification - Show detailed summary of changes when run without --write
why: Wire up the fmt command to the main CLI interface what: - Import fmt module and format_config_file function - Add fmt_parser to subparsers with help text - Add fmt handling in cli() function with config and write arguments - Update create_parser return tuple to include fmt_parser
why: Ensure fmt command works correctly with various config formats what: - Add TestNormalizeRepoConfig class for testing repo normalization - Add TestFormatConfig class for testing config formatting logic - Add TestFormatConfigFile class for testing file operations - Test compact to verbose format conversion - Test url to repo key conversion - Test directory and repository sorting - Test --write flag behavior and dry-run mode - Add clear_logging_handlers fixture to prevent test interference
why: mypy reported type errors when unpacking kwargs to format_config_file what: - Remove intermediate fmt_kwargs dictionary - Pass arguments directly to format_config_file in correct order - Fixes incompatible type errors for both arguments refs: mypy error: "Argument 1 to format_config_file has incompatible type"
…mplify argument passing why: Argparse always adds attributes to namespace with defaults, making hasattr checks redundant what: - Remove all hasattr checks for argparse attributes - Simplify sync call by directly accessing args attributes - Remove intermediate dictionary building for add and add_from_fs - Pass arguments directly to functions instead of using **kwargs - Cleaner and more readable code refs: All argparse arguments have defaults (None, False, or empty list) so attributes always exist
why: Ensure consistent code formatting what: - Remove unused yaml import - Fix trailing whitespace - Add newline at end of file
why: Test suite was failing when run together due to fixture conflicts what: - Add vcspull.cli.fmt to list of loggers cleared in fixtures - Rename clear_logging_handlers to reset_logging in test_fmt.py to avoid conflicts - Update test_fmt.py tests to use reset_logging fixture refs: Fixture isolation issue - clear_logging_handlers with autouse=True affects all tests
why: vcspull.cli.fmt was missing from the list of CLI loggers that get SimpleLogFormatter, causing it to fall back to DebugLogFormatter which outputs to stderr and bypasses pytest's log capture. what: - Add 'vcspull.cli.fmt' to cli_loggers list in setup_logger function - Ensures fmt module gets same clean output formatting as other CLI modules refs: Fixes test failures in test_fmt.py when run after test_log.py
…erference why: Tests were failing when run after test_log.py because setup_logger() created StreamHandlers that bypassed pytest's log capture mechanism. what: - Update reset_logging fixture to clear handlers before AND after tests - Re-enable log propagation so pytest can capture logs properly - Add libvcs to list of loggers to clear - Make fixture autouse and remove unnecessary parameters from test methods - Match the pattern used in test_add.py and test_add_from_fs.py refs: Fixes all 7 failing tests in TestFormatConfigFile class
why: Users need a way to format all their vcspull configuration files at once, similar to how sync discovers and processes all configs. what: - Add --all flag to fmt command argument parser - Refactor format_config_file() into format_single_config() for individual files - Update format_config_file() to handle both single file and --all modes - Discover configs using find_config_files(include_home=True) when --all is used - Include local .vcspull.yaml/json files in current directory - Add clear progress reporting showing all files found and their status - Add summary at the end showing success count - Update existing tests to pass new format_all parameter - Add comprehensive test for --all functionality with mocked config discovery - Fix type annotations for test helper functions refs: Enhancement to make vcspull fmt more powerful for managing multiple configs
Applied automatic fixes from ruff including: - Remove unused variables and replace with underscore prefix - Fix import ordering - Remove trailing whitespace - Add trailing commas - Fix type annotation formatting - Simplify conditional logic
why: Address B007, SIM102, PERF102, and E501 linting violations to maintain code quality standards. what: - Replace unused loop variable with underscore prefix - Combine nested if statements using logical and operators - Use values() instead of items() when keys are not needed - Split long conditional statement across multiple lines for readability refs: ruff check compliance
f310106
to
9c5c92e
Compare
Fixes:
add-from-fs
#25Summary by Sourcery
Add new CLI commands
add
andadd-from-fs
to vcspull for managing repository configurationNew Features:
add
command to add a single repository to vcspull configurationadd-from-fs
command to scan and add multiple git repositories from a directoryEnhancements: