Skip to content

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

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft

New commands: add and add-from-fs #465

wants to merge 17 commits into from

Conversation

tony
Copy link
Member

@tony tony commented May 10, 2025

Fixes:

Summary by Sourcery

Add new CLI commands add and add-from-fs to vcspull for managing repository configuration

New Features:

  • Implement add command to add a single repository to vcspull configuration
  • Implement add-from-fs command to scan and add multiple git repositories from a directory

Enhancements:

  • Extend CLI parser to support new subcommands
  • Improve configuration file handling with more flexible path and key management

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 from 8508e50 to e1fe48f Compare May 10, 2025 15:03
@tony tony force-pushed the scanner-and-add branch from a36fbef to 69a222e Compare May 10, 2025 16:36
Copy link

codecov bot commented May 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.98%. Comparing base (07be56b) to head (8ef69e9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #465   +/-   ##
=======================================
  Coverage   78.98%   78.98%           
=======================================
  Files           8        8           
  Lines         414      414           
  Branches       85       85           
=======================================
  Hits          327      327           
  Misses         52       52           
  Partials       35       35           

☔ 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 added 12 commits May 10, 2025 14:31
Make config parameter in sync function explicitly optional in type signature to match actual behavior. This improves type checking without changing functionality.
This commit adds two new CLI commands to vcspull:

1. 'add' - Adds a single repository to the configuration
   - Handles different input formats (name=url, url only)
   - Supports custom base_dir_key and target_path options
   - Automatically extracts repo names from URLs when needed

2. 'add-from-fs' - Scans a directory for git repositories and adds them to the configuration
   - Supports recursive scanning with --recursive flag
   - Can use a custom base directory key with --base-dir-key
   - Provides interactive confirmation (can be bypassed with --yes)
   - Organizes nested repositories under appropriate base keys

Both commands include thorough test coverage and maintain project code style.
@tony tony force-pushed the scanner-and-add branch from 8ef69e9 to 6cf08d3 Compare May 10, 2025 19:31
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.

1 participant