Skip to content

Commit 3df7f4e

Browse files
authored
feat(config,cli) Numeric clone depth, sync keys under options: (#554)
vcspull can now keep a small window of git history per repository via a numeric `options.depth: N`, instead of the all-or-nothing `shallow: true`. The per-repository sync-tuning keys (`rev`, `shallow`, `depth`) move into an `options:` block alongside the existing mutation policy, and a new `vcspull migrate` command rewrites configs from the older top-level form. Builds on the rev-pinning and shallow-detection work from v1.61.0. Fixes #552. - **Numeric depth:** `add` and `discover` accept `--depth N` (clone `--depth N` on sync) and auto-detect an existing checkout's depth — recording `options.shallow: true` for a depth-1 clone and `options.depth: N` for a deeper window. `depth` wins over `shallow`. - **options: block:** `rev`/`shallow`/`depth` are written under `options:` (joining `pin`/`pin_reason`), keeping the entry root to the repo URL, remotes, and worktrees. - **vcspull migrate:** new subcommand (mirrors `fmt`: `-f/--file`, `--write`, `--all`) that relocates top-level keys into `options:`; previews by default and is idempotent on re-run. - **Deprecation warning:** `vcspull sync` warns when it reads a config still using the top-level form and points at `vcspull migrate`. Breaking changes: The `rev:` and `shallow:` keys that shipped at the repository entry root in v1.61.0 are deprecated in favor of the `options:` block. They are still read (with a warning), so existing configs keep working; run `vcspull migrate --write` to update them. # Before ~/code/: flask: repo: git+https://github.com/pallets/flask.git shallow: true # After ~/code/: flask: repo: git+https://github.com/pallets/flask.git options: shallow: true Dependencies: Minimum libvcs >= 0.42.0 (was >= 0.41.0) — its GitSync honors an arbitrary clone depth, which `options.depth: N` relies on.
2 parents 37b2c53 + 597104f commit 3df7f4e

23 files changed

Lines changed: 1895 additions & 79 deletions

CHANGES

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,53 @@ $ uvx --from 'vcspull' --prerelease allow vcspull
3737
_Notes on upcoming releases will be added here_
3838
<!-- END PLACEHOLDER - ADD NEW CHANGELOG ENTRIES BELOW THIS LINE -->
3939

40+
### Breaking changes
41+
42+
#### Per-repository sync keys now live under `options:` (#552)
43+
44+
The per-repository `rev`, `shallow`, and new `depth` keys are written under an
45+
`options:` block instead of the entry root. The top-level form that shipped in
46+
v1.61.0 is still read, but {ref}`cli-sync` warns when it encounters it. Run
47+
{ref}`cli-migrate` to rewrite existing configs:
48+
49+
```yaml
50+
# Before
51+
~/code/:
52+
flask:
53+
repo: git+https://github.com/pallets/flask.git
54+
shallow: true
55+
56+
# After
57+
~/code/:
58+
flask:
59+
repo: git+https://github.com/pallets/flask.git
60+
options:
61+
shallow: true
62+
```
63+
64+
### Dependencies
65+
66+
#### Minimum `libvcs>=0.42.0` (was `>=0.41.0`)
67+
68+
libvcs 0.42.0 teaches its git backend an arbitrary clone depth, which the new
69+
`depth: N` key relies on.
70+
71+
### What's new
72+
73+
#### Numeric clone depth (#552)
74+
75+
A repository can keep a small window of history with `options.depth: N` (clone
76+
with `--depth N`) instead of the all-or-nothing `shallow: true`. {ref}`cli-add`
77+
and {ref}`cli-discover` accept `--depth N` and detect an existing checkout's
78+
depth automatically—recording `shallow: true` for a depth-1 checkout and
79+
`depth: N` for a deeper window. See {ref}`configuration`.
80+
81+
#### Migrate configs to the `options:` form (#552)
82+
83+
{ref}`cli-migrate` rewrites configuration files that still carry top-level
84+
`rev`/`shallow`/`depth`, moving them under `options:`. It previews changes by
85+
default and applies them with `--write`.
86+
4087
## vcspull v1.61.0 (2026-05-30)
4188

4289
vcspull v1.61.0 lets `add` and `discover` capture per-repository git state when

MIGRATION

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,41 @@ well.
2121

2222
## Next release
2323

24-
_Notes on the upcoming release will be added here_
24+
### Per-repository sync keys moved under `options:`
25+
26+
_via #552_
27+
28+
The per-repository `rev`, `shallow`, and the new `depth` keys are now written
29+
under an `options:` block instead of the repository entry root. The top-level
30+
form still loads, but `vcspull sync` now warns when it reads it and points you
31+
here. Rewrite your configs in place:
32+
33+
```console
34+
$ vcspull migrate --write
35+
```
36+
37+
Before:
38+
39+
```yaml
40+
~/code/:
41+
flask:
42+
repo: git+https://github.com/pallets/flask.git
43+
shallow: true
44+
```
45+
46+
After:
47+
48+
```yaml
49+
~/code/:
50+
flask:
51+
repo: git+https://github.com/pallets/flask.git
52+
options:
53+
shallow: true
54+
```
55+
56+
`depth: N` is new — record a numeric clone depth (`git clone --depth N`) when a
57+
boolean `shallow` (depth 1) is too little. See {ref}`configuration` and
58+
{ref}`cli-migrate`.
2559

2660
<!-- Maintainers, insert changes / features for the next release here -->
2761

docs/cli/index.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ Scan directories for existing repos.
4949
Normalize and format config files.
5050
:::
5151

52+
:::{grid-item-card} vcspull migrate
53+
:link: migrate
54+
:link-type: doc
55+
Move rev/shallow/depth under options:.
56+
:::
57+
5258
:::{grid-item-card} vcspull import
5359
:link: import/index
5460
:link-type: doc
@@ -82,6 +88,7 @@ search
8288
status
8389
worktree/index
8490
fmt
91+
migrate
8592
```
8693

8794
```{toctree}
@@ -105,5 +112,5 @@ completion
105112
:nosubcommands:
106113
107114
subparser_name : @replace
108-
See :ref:`cli-sync`, :ref:`cli-add`, :ref:`cli-import`, :ref:`cli-discover`, :ref:`cli-list`, :ref:`cli-search`, :ref:`cli-status`, :ref:`cli-worktree`, :ref:`cli-fmt`
115+
See :ref:`cli-sync`, :ref:`cli-add`, :ref:`cli-import`, :ref:`cli-discover`, :ref:`cli-list`, :ref:`cli-search`, :ref:`cli-status`, :ref:`cli-worktree`, :ref:`cli-fmt`, :ref:`cli-migrate`
109116
```

docs/cli/migrate.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
(cli-migrate)=
2+
3+
# vcspull migrate
4+
5+
`vcspull migrate` rewrites configuration files to the current schema, moving the
6+
per-repository `rev`, `shallow`, and `depth` keys from the entry root into the
7+
`options:` block. By default it prints the proposed changes; apply them in place
8+
with `--write`.
9+
10+
These keys shipped at the entry root in vcspull v1.61.0. They are still read,
11+
but {ref}`cli-sync` warns when it encounters them. Migrating clears the warning
12+
and keeps configs on the supported shape.
13+
14+
## Command
15+
16+
```{eval-rst}
17+
.. argparse::
18+
:module: vcspull.cli
19+
:func: create_parser
20+
:prog: vcspull
21+
:path: migrate
22+
```
23+
24+
## What gets migrated
25+
26+
For each repository entry, a top-level `rev`, `shallow`, or `depth` key is moved
27+
under `options:`. A value already present under `options:` wins, and `depth`
28+
takes precedence over `shallow`. Entries already on the `options:` form, string
29+
shorthands, and unrelated keys are left untouched.
30+
31+
Given:
32+
33+
```yaml
34+
~/code/:
35+
flask:
36+
repo: git+https://github.com/pallets/flask.git
37+
rev: v3.0.0
38+
shallow: true
39+
```
40+
41+
`vcspull migrate --write` produces:
42+
43+
```yaml
44+
~/code/:
45+
flask:
46+
repo: git+https://github.com/pallets/flask.git
47+
options:
48+
rev: v3.0.0
49+
shallow: true
50+
```
51+
52+
## Writing changes
53+
54+
Preview the rewrite first:
55+
56+
```console
57+
$ vcspull migrate --file ~/.vcspull.yaml
58+
```
59+
60+
Then add `--write` to persist it:
61+
62+
```console
63+
$ vcspull migrate \
64+
--file ~/.vcspull.yaml \
65+
--write
66+
```
67+
68+
Use `--all` to iterate over the default search locations: the current working
69+
directory, `~/.vcspull.*`, and the XDG configuration directory.
70+
71+
```console
72+
$ vcspull migrate --all --write
73+
```
74+
75+
Migration is idempotent—running it again on an already-migrated file makes no
76+
changes.
77+
78+
## See also
79+
80+
- {ref}`configuration` — the `options:` block and its sync-tuning keys.
81+
- {ref}`migration` — the deprecation note for the top-level form.

docs/configuration/index.md

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,41 +119,83 @@ Optional fields:
119119

120120
See {ref}`cli-worktree` for full command documentation.
121121

122-
## Revision pinning
122+
## Sync options
123123

124-
A `rev:` key pins a repository to a commit, tag, or branch, which {ref}`cli-sync`
125-
checks out. This lets a config capture a reproducible snapshot instead of
126-
tracking the branch tip. It is distinct from `options.pin` (see
124+
Per-repository sync behavior lives under an `options:` block alongside the
125+
`repo` URL. The keys below tune how {ref}`cli-sync` clones and updates a
126+
checkout. Mutation policy such as `pin` lives in the same block (see
127+
{ref}`config-pin`).
128+
129+
### Revision pinning
130+
131+
`options.rev` pins a repository to a commit, tag, or branch, which
132+
{ref}`cli-sync` checks out. This lets a config capture a reproducible snapshot
133+
instead of tracking the branch tip. It is distinct from `options.pin` (see
127134
{ref}`config-pin`), which guards the config entry from being overwritten rather
128135
than pinning a git ref.
129136

130137
```yaml
131138
~/code/:
132139
flask:
133140
repo: git+https://github.com/pallets/flask.git
134-
rev: v3.0.0
141+
options:
142+
rev: v3.0.0
135143
```
136144
137145
`vcspull add <path> --pin <ref>` and `vcspull discover <dir> --pin <ref>` record
138146
this key when importing an existing checkout. See {ref}`cli-add` and
139147
{ref}`cli-discover`.
140148

141-
## Shallow clones
149+
### Shallow clones
142150

143-
A `shallow: true` key makes {ref}`cli-sync` clone the repository with
151+
`options.shallow: true` makes {ref}`cli-sync` clone the repository with
144152
`--depth 1`, trading git history for disk and time—useful for workspaces with
145153
many repositories.
146154

147155
```yaml
148156
~/code/:
149157
flask:
150158
repo: git+https://github.com/pallets/flask.git
151-
shallow: true
159+
options:
160+
shallow: true
161+
```
162+
163+
`vcspull add` and `vcspull discover` detect an existing depth-1 checkout
164+
automatically and record `options.shallow: true`; the `--shallow` flag forces it
165+
on even for a full checkout.
166+
167+
### Clone depth
168+
169+
`options.depth: N` keeps a small window of history by cloning with `--depth N`.
170+
Reach for it when `shallow: true` (depth 1) is too little—for example, a handful
171+
of recent commits for `git log` or `git bisect`.
172+
173+
```yaml
174+
~/code/:
175+
django:
176+
repo: git+https://github.com/django/django.git
177+
options:
178+
depth: 50
179+
```
180+
181+
`vcspull add <path> --depth N` and `vcspull discover <dir> --depth N` record this
182+
key. When importing an existing shallow checkout, both detect its depth: a
183+
depth-1 checkout records `options.shallow: true` and a deeper window records
184+
`options.depth: N`. `depth` takes precedence over `shallow` when both are set.
185+
186+
### Migrating from the top-level form
187+
188+
vcspull v1.61.0 accepted `rev:` and `shallow:` at the repository entry root.
189+
Those keys still work but are deprecated in favor of the `options:` block, and
190+
{ref}`cli-sync` warns when it reads them. Run {ref}`cli-migrate` to rewrite
191+
existing configs in place:
192+
193+
```console
194+
$ vcspull migrate --write
152195
```
153196

154-
`vcspull add` and `vcspull discover` detect an existing shallow checkout
155-
automatically and record `shallow: true`; the `--shallow` flag forces it on even
156-
for a full checkout.
197+
See {ref}`migration` for the deprecation note and {ref}`cli-migrate` for the
198+
command reference.
157199

158200
(config-pin)=
159201

docs/internals/api/cli/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ search
1717
status
1818
worktree
1919
fmt
20+
migrate
2021
```
2122

2223
## vcspull CLI - `vcspull.cli`

docs/internals/api/cli/migrate.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# vcspull migrate - `vcspull.cli.migrate`
2+
3+
```{eval-rst}
4+
.. automodule:: vcspull.cli.migrate
5+
:members:
6+
:show-inheritance:
7+
:undoc-members:
8+
```

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ keywords = [
5353
]
5454
homepage = "https://vcspull.git-pull.com"
5555
dependencies = [
56-
"libvcs>=0.41.0,<0.42.0",
56+
"libvcs>=0.42.0,<0.43.0",
5757
"colorama>=0.3.9",
5858
"PyYAML>=6.0"
5959
]

0 commit comments

Comments
 (0)