Skip to content

Commit f566a30

Browse files
committed
docs(cli[add]) Document adding a repository by URL
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
1 parent 78bd193 commit f566a30

1 file changed

Lines changed: 50 additions & 11 deletions

File tree

docs/cli/add.md

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
# vcspull add
44

5-
The `vcspull add` command registers a repository in your
6-
{ref}`configuration <configuration>` by pointing vcspull at a checkout on
7-
disk. The command inspects the directory,
8-
merges duplicate workspace roots by default, and prompts before writing unless
9-
you pass `--yes`.
5+
The `vcspull add` command registers a single repository in your
6+
{ref}`configuration <configuration>`. Point it at a checkout on disk and it
7+
reads the details out of the directory; give it a repository URL and it records
8+
the entry without cloning anything, leaving the working tree to
9+
{ref}`vcspull sync <cli-sync>`. Either way it merges duplicate workspace roots
10+
by default and prompts before writing unless you pass `--yes`.
1011

1112
```{note}
1213
This command replaces the old `vcspull import <name> <url>` from v1.36--v1.39.
@@ -43,6 +44,37 @@ The parent directory (`~/study/python/` in this example) becomes the workspace
4344
root. vcspull shortens paths under `$HOME` to `~/...` in its log output so the
4445
preview stays readable.
4546

47+
## Declaring a repository you have not cloned
48+
49+
Pass a repository URL instead of a path when you want the entry in your
50+
configuration but do not have the code yet:
51+
52+
```vcspull-console
53+
$ vcspull add https://github.com/pallets/flask.git
54+
Found new repository to import:
55+
+ flask (https://github.com/pallets/flask.git)
56+
• workspace: ~/code/
57+
↳ path: ~/code/flask
58+
• workspace roots in ~/.vcspull.yaml:
59+
1) ~/code/ (default)
60+
2) ~/study/python/
61+
? Import this repository? [y/N/1-2]: y
62+
✓ Successfully added 'flask' (git+https://github.com/pallets/flask.git) to ~/.vcspull.yaml under '~/code/'.
63+
```
64+
65+
The repository name comes from the URL — `flask` here — unless you pass
66+
`--name`. Nothing is fetched: the entry lands in your configuration and
67+
{ref}`vcspull sync <cli-sync>` clones it the next time you run it.
68+
69+
Because there is no parent directory to infer a workspace from, vcspull offers
70+
the workspace roots your configuration already declares. Answering `y` accepts
71+
the default, answering with a number picks a different root, and `--workspace`
72+
names one outright and skips the list. When the configuration declares no roots
73+
yet, the current directory becomes the workspace.
74+
75+
A directory on disk always wins. If the argument names something that exists,
76+
vcspull treats it as a path even when the same text would also parse as a URL.
77+
4678
## Overriding detected information
4779

4880
### Choose a different name
@@ -63,13 +95,18 @@ need to register a different remote or when the checkout does not have one yet:
6395
$ vcspull add ~/study/python/example --url https://github.com/org/example
6496
```
6597

98+
`--url` accompanies a path. When the argument is already a URL, pass it once and
99+
leave `--url` off — supplying both is ambiguous, so vcspull stops rather than
100+
guessing which one you meant.
101+
66102
URLs follow [pip's VCS format][pip vcs url]; vcspull inserts the `git+` prefix
67103
for HTTPS URLs so the resulting configuration matches
68104
{ref}`vcspull fmt <cli-fmt>` output.
69105

70106
### Select a workspace explicitly
71107

72-
The workspace defaults to the checkout's parent directory. Pass
108+
The workspace defaults to the checkout's parent directory, or — when you add by
109+
URL — to the first workspace root your configuration declares. Pass
73110
`--workspace`/`--workspace-root` to store the repository under a different
74111
section:
75112

@@ -152,15 +189,17 @@ by `vcspull add`:
152189

153190
```diff
154191
- $ vcspull import flask https://github.com/pallets/flask.git -c ~/.vcspull.yaml
155-
+ $ vcspull add ~/code/flask --url https://github.com/pallets/flask.git --file ~/.vcspull.yaml
192+
+ $ vcspull add https://github.com/pallets/flask.git --file ~/.vcspull.yaml
156193
```
157194

158195
Key differences:
159196

160-
- `vcspull add` derives the name from the filesystem unless you pass `--name`.
161-
- The parent directory becomes the workspace automatically; use `--workspace`
162-
to override.
163-
- Use `--url` to record a remote when the checkout does not have one.
197+
- `vcspull add` derives the name from the URL, or from the directory when you
198+
add a checkout, unless you pass `--name`.
199+
- The workspace comes from the checkout's parent directory, or from the
200+
workspace roots your configuration declares when you add by URL; use
201+
`--workspace` to override either.
202+
- Use `--url` to record a remote when a checkout does not have one.
164203

165204
```{note}
166205
Starting with v1.55, `vcspull import` is a *different* command that bulk-imports

0 commit comments

Comments
 (0)