cli(add): accept a repository URL, not only a checkout path#563
Open
tony wants to merge 3 commits into
Open
Conversation
why: Declaring a repository that is not checked out yet required hand-editing the YAML. `vcspull add` gated on the path existing, and `--url` only overrode the remote detected from a checkout, so there was no CLI route from "I know the URL" to a config entry. URL-first adding existed as `vcspull import <name> <url>` through v1.39 and was dropped when `add` became path-first; `import` now belongs to the forge importers, so the capability comes back on `add` instead. what: - Accept either a filesystem path or a repository URL as the `add` argument, discriminated with libvcs `GitURL.is_valid` - Resolve an existing directory before considering a URL, so every path-mode invocation keeps its current behavior - Derive the repo name from the URL basename, still overridable with `--name`; reject a URL argument combined with `--url` - Offer workspace roots already declared in the config when a URL has no `--workspace`, defaulting to the first and falling back to the current directory; fold the choice into the existing confirm prompt - Extract config-file resolution into `_resolve_config_file` so the prompt can read declared roots before the write path runs - Cover URL forms, root selection, decline paths, and path-wins precedence in tests/cli/test_add.py
why: The page framed `add` as pointing vcspull at a checkout on disk, which is now only half of what the command accepts, and the migration diff still routed the old `vcspull import <name> <url>` through a path plus `--url`. what: - Reframe the intro around both forms and say the URL form records the entry without cloning - Add a section covering name derivation from the URL, the workspace roots offered when `--workspace` is absent, and the rule that an existing directory wins over a URL-shaped argument - Note that `--url` accompanies a path and is rejected alongside a URL - Restore the near-1:1 migration diff from the old import command
why: Record the new `vcspull add <url>` surface for the v1.66 entry.
Member
Author
Code reviewFound 2 issues:
vcspull/src/vcspull/cli/add.py Lines 315 to 332 in a5754e6
Lines 41 to 47 in a5754e6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vcspull add: pass a repository URL and it records the config entry without cloning, leaving the checkout tovcspull sync. Previouslyaddrequired an existing directory on disk, so declaring a not-yet-cloned repo meant hand-editing YAML.GitURL.is_validto discriminate path from URL, with an existing directory always winning — every current path-mode invocation behaves exactly as before.--workspace, since there is no parent directory to derive one from. The choice folds into the existing confirm prompt rather than adding a second one.Changes
src/vcspull/cli/add.py: Discriminate therepo_pathargument as path-or-URL inhandle_add_command. Derive the repo name from the URL basename (overridable with--name), reject a URL argument combined with--url, and offer declared workspace roots in the confirm prompt. Extract config-file resolution into_resolve_config_file/ConfigFileResolutionso the prompt can read declared roots before the write path runs; add_repo_name_from_urland_declared_workspace_labelshelpers.tests/cli/test_add.py: Parameterized URL-mode coverage — URL forms (https, scp,git+), first-root default and numeric selection, decline and out-of-range paths,--workspaceoverride, no-declared-roots fallback to cwd, name override, the redundant---urlerror, and path-wins precedence on an argument that is simultaneously a valid scp URL and a legal directory name.docs/cli/add.md: Reframe the intro around both forms, add a "Declaring a repository you have not cloned" section, and restore the near-1:1 migration diff from the oldvcspull import <name> <url>.CHANGES: v1.66 "What's new" entry.Design decisions
--urlkeeps its single meaning as a remote override for path mode. Avcspull declaresubcommand would reopen the naming churn thatimportalready went through.GitURL.is_valid, so a path that also parses as a URL stays a path. This is the compatibility guarantee — no current invocation changes behavior.--cloneflag:vcspull syncalready clones with progress, parallelism, and per-VCS handling. A clone flag would duplicate a better implementation and makeaddthe first config command to mutate a working tree.-y,--dry-run, EOF) take the default root silently, consistent with how-yalready auto-confirms.Test plan
uv run pytest tests/cli/test_add.py— new URL-mode cases plus unchanged path-mode snapshotsuv run pytest— full suite greenuv run ruff format --check .anduv run ruff check .— cleanuv run mypy— cleanjust build-docs— build succeeded, no new warnings