Skip to content

Conversation

tony
Copy link
Member

@tony tony commented May 10, 2025

Changes

New: Added vcspull fmt

  • Introduces a fmt subcommand to normalize configuration files (sort directories/repos, convert compact entries to verbose {repo: ...} form, and standardize keys).
  • Example: uv run vcspull fmt --config ~/.vcspull.yaml --write

New: Added vcspull add

  • Adds a single repository entry to the configuration with flexible base directory detection.
  • Example: uv run vcspull add myrepo git@github.com:user/myrepo.git --dir ~/code

New: Added vcspull add-from-fs

  • Scans a directory (optionally recursively) for git repositories and appends new entries to the configuration, prompting for confirmation unless --yes is specified.
  • Example: uv run vcspull add-from-fs ~/study/typescript --config ~/.vcspull.yaml --yes

Logging Improvements

  • Replace the import-time NullHandler with a configured stdout StreamHandler to restore CLI output after the logging refactor.
  • Ensure handlers survive pytest stream rotation via safe flush/reset logic.
  • Added regression test test_add_from_fs_stream_output to guarantee user-facing output remains visible.

Config & CLI Enhancements

  • ConfigReader now reads files using UTF-8 explicitly.
  • Shared helper save_config_yaml centralizes YAML writes with UTF-8 encoding.
  • CLI parser now wires in the new subcommands and routes to dedicated modules.

Fixes: #25, #333

Testing

  • uv run ruff check src/vcspull/log.py tests/cli/test_add_from_fs.py
  • uv run mypy
  • uv run py.test

Additional Notes

  • Extensive new CLI tests cover add/add-from-fs/fmt behaviors, including duplicate detection, confirmation prompts, and formatting summaries.
  • Logging test suite expanded to validate handler configuration, propagation, and formatter integration.

Copy link

sourcery-ai bot commented May 10, 2025

Reviewer's Guide

This pull request introduces two new CLI subcommands, add and add-from-fs, to vcspull, enhancing its repository management capabilities. The add command is implemented in src/vcspull/cli/add.py and allows users to manually specify repository details (URL, name, target path) for addition to the YAML configuration. The add-from-fs command, housed in src/vcspull/cli/add_from_fs.py, scans a specified filesystem directory for Git repositories, automatically extracts their remote 'origin' URLs, and adds them to the configuration, optionally after user confirmation. Both functionalities are integrated into the main CLI by updating src/vcspull/cli/__init__.py to include new argument subparsers and modify the command dispatch logic. This involved refactoring create_parser to manage and return a collection of all subparsers and updating the cli function to robustly pass arguments to the respective command handlers.

File-Level Changes

Change Details Files
Implemented add command for manual repository addition to the configuration.
  • Created add.py module with logic to parse repository details (URL, name, path) and update the YAML configuration.
  • Defined command-line arguments for the add subparser within add.py.
  • Integrated the add subparser and its handler into the main CLI structure in __init__.py.
src/vcspull/cli/add.py
src/vcspull/cli/__init__.py
Implemented add-from-fs command to discover local Git repositories and add them to the configuration.
  • Created add_from_fs.py module with logic to scan directories, extract Git remote URLs, and update the configuration, including an interactive confirmation step.
  • Defined command-line arguments for the add-from-fs subparser within add_from_fs.py.
  • Integrated the add-from-fs subparser and its handler into the main CLI structure in __init__.py.
src/vcspull/cli/add_from_fs.py
src/vcspull/cli/__init__.py
Refactored CLI argument parsing and command dispatching in __init__.py.
  • Modified create_parser function to support the registration and retrieval of multiple subparsers.
  • Updated the main cli function to correctly dispatch to the new command handlers based on the invoked subparser.
  • Improved argument handling when calling command handlers by checking for attribute existence on the parsed arguments object.
src/vcspull/cli/__init__.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@tony tony changed the title !squash initial: add and add-from-fs New commands: add and add-from-fs May 10, 2025
@tony tony force-pushed the scanner-and-add branch 2 times, most recently from a36fbef to 69a222e Compare May 10, 2025 16:36
Copy link

codecov bot commented May 10, 2025

Codecov Report

❌ Patch coverage is 72.43902% with 113 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.70%. Comparing base (60d3f70) to head (c5dfc5e).

Files with missing lines Patch % Lines
src/vcspull/cli/add_from_fs.py 70.37% 29 Missing and 11 partials ⚠️
src/vcspull/cli/fmt.py 74.80% 20 Missing and 13 partials ⚠️
src/vcspull/cli/add.py 60.00% 23 Missing and 7 partials ⚠️
src/vcspull/log.py 87.30% 3 Missing and 5 partials ⚠️
src/vcspull/cli/sync.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #465      +/-   ##
==========================================
- Coverage   78.93%   76.70%   -2.24%     
==========================================
  Files           8       11       +3     
  Lines         413      807     +394     
  Branches       85      184      +99     
==========================================
+ Hits          326      619     +293     
- Misses         52      119      +67     
- Partials       35       69      +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tony tony force-pushed the scanner-and-add branch 3 times, most recently from d37cb7e to 628830e Compare May 17, 2025 11:49
@tony tony force-pushed the scanner-and-add branch 3 times, most recently from e85482d to e26036d Compare June 1, 2025 11:07
@tony tony force-pushed the scanner-and-add branch 6 times, most recently from 740c98c to 1045626 Compare June 22, 2025 14:09
@tony tony force-pushed the scanner-and-add branch from ca15fce to c68f1d5 Compare June 28, 2025 11:57
@tony tony force-pushed the scanner-and-add branch from c68f1d5 to 32bbbd8 Compare July 5, 2025 12:09
@tony tony force-pushed the scanner-and-add branch from 1a6b722 to 40c47a6 Compare July 12, 2025 14:02
@tony tony force-pushed the scanner-and-add branch from 40c47a6 to 1e1becb Compare July 20, 2025 21:06
@tony tony force-pushed the scanner-and-add branch 9 times, most recently from b02d442 to 27d3297 Compare September 4, 2025 11:08
@tony tony force-pushed the scanner-and-add branch 2 times, most recently from f310106 to 9c5c92e Compare September 5, 2025 15:15
@tony tony force-pushed the scanner-and-add branch 6 times, most recently from 1be9760 to 81eb435 Compare October 5, 2025 18:35
tony added 2 commits October 5, 2025 18:26
…g fixes

why:
- expose configuration management (add, add-from-fs, fmt) through the main CLI
- keep user-facing output visible after the logging refactor
- ensure default config readers use UTF-8 consistently

what:
- wire add/add-from-fs/fmt subcommands into `vcspull` CLI entry and parser
- implement `cli/add.py`, `cli/add_from_fs.py`, `cli/fmt.py` plus extensive tests
- centralize config saves via `save_config_yaml` and open configs as UTF-8
- refactor `setup_logger` to replace NullHandler with stdout stream and add
  regression test for CLI output
- expand logging test suite to cover formatter and propagation behavior

This keeps the subject succinct while the bullets break down the “why/what” of
the large diff. Adjust component prefixes as needed if you prefer more
granularity (e.g., separate commits per concern), but this structure documents
all the key changes in one place.
@tony tony force-pushed the scanner-and-add branch from aefcf5a to c5dfc5e Compare October 5, 2025 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scan for vcs repos and save, ignore feature, add-from-fs
1 participant