Skip to content

Commit 21c20f9

Browse files
authored
config(feat): Add targets, VCS blocks, and schema (#589)
why: Repository entries mixed checkout targets, backend flags, and pin policy under untyped options dicts without editor validation. what: - Validate shared working_copy and worktrees targets, remotes, and sync policies alongside git, hg, and svn backend option blocks - Migrate legacy options and <vcs>_options layouts in vcspull migrate and vcspull fmt, exiting 1 on invalid entries - Publish Draft 2020-12 JSON Schema with filter completions and hover descriptions without adding runtime CLI imports - Honor repository pins before vcspull import tags provenance - Require libvcs>=0.47.0,<0.48.0 Fixes #576, fixes #369, fixes #376
2 parents ef6e057 + efbb876 commit 21c20f9

38 files changed

Lines changed: 6542 additions & 683 deletions

‎.github/CONTRIBUTING.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,25 @@ the one edit that silently deletes a doctest, are in
6262
Before claiming a test or a gate works, show it failing. A gate that has
6363
never been red is an assumption.
6464

65+
### Configuration schema
66+
67+
Regenerate the published editor schema after changing configuration types or
68+
validation, using the first Python version in `.tool-versions`:
69+
70+
```console
71+
$ uv run python scripts/generate_schema.py
72+
```
73+
74+
Check the committed artifact without writing:
75+
76+
```console
77+
$ uv run python scripts/generate_schema.py --check
78+
```
79+
80+
The agreement tests validate original documents with standard JSON Schema
81+
and the config loader. Schema dependencies belong in the development group;
82+
keep them out of runtime imports.
83+
6584
### Imports and typing
6685

6786
- `from __future__ import annotations` at the top of every file — `ruff`'s

‎CHANGES‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,96 @@ _Notes on upcoming releases will be added here_
4545
Python 3.10 reached end-of-life in October 2026. vcspull now requires Python
4646
3.11 or newer.
4747

48+
#### Configuration loading validates repository entries strictly (#589)
49+
50+
Configuration loading now rejects unknown repository, target, policy, or backend
51+
option keys, mismatched VCS option blocks, integers outside `-(2**53 - 1)` to
52+
`2**53 - 1`, non-JSON `metadata` values, raw `combine:` filter strings, and
53+
unprefixed SCP URLs whose path starts with a non-ASCII character without `vcs`.
54+
Run {ref}`cli-migrate` with `--write` to rewrite legacy `options` and
55+
`<vcs>_options` entries into `working_copy`, backend blocks, and entry-level
56+
`pin` fields.
57+
58+
```yaml
59+
# Before
60+
~/code/:
61+
libvcs:
62+
repo: git+https://github.com/vcs-python/libvcs.git
63+
options:
64+
rev: v0.46.0
65+
shallow: true
66+
pin:
67+
import: true
68+
69+
# After
70+
~/code/:
71+
libvcs:
72+
repo: git+https://github.com/vcs-python/libvcs.git
73+
working_copy:
74+
rev: v0.46.0
75+
git:
76+
depth: 1
77+
pin:
78+
import: true
79+
```
80+
81+
### Dependencies
82+
83+
#### Require libvcs 0.47.0 (#589)
84+
85+
Minimum `libvcs>=0.47.0,<0.48.0` (was `>=0.46.0,<0.47.0`).
86+
87+
### What's new
88+
89+
#### Configure partial clones and typed backend options (#589)
90+
91+
`git`, `hg`, and `svn` blocks match their libvcs options classes. Loading
92+
rejects unknown fields, invalid values, and blocks for a different VCS before
93+
sync starts. Errors identify the file, workspace, repository, and field.
94+
Overridden legacy values are validated too. Integer fields accept integral
95+
numbers such as `2.0`; metadata accepts JSON-compatible values.
96+
97+
```yaml
98+
~/code/:
99+
git:
100+
repo: git+https://github.com/git/git.git
101+
git:
102+
filter: blob:none
103+
```
104+
105+
Partial clones retain commit history and fetch file contents on demand.
106+
Existing checkouts keep their depth and filter. Legacy option locations load
107+
with a migration warning. `pin`, `pin_reason`, and `allow_overwrite` also work
108+
at the repository entry level.
109+
110+
#### Complete and validate configuration in editors (#589)
111+
112+
The published JSON Schema describes backend options, partial-clone filter kinds
113+
and string completions, shared checkout targets, remote URLs, and entry policy,
114+
with hover descriptions on option and filter fields. Add the
115+
`yaml-language-server` schema directive shown in {ref}`configuration` for
116+
editor completion and validation. The CLI keeps its runtime validation
117+
independent of schema-generation dependencies. Numeric settings use exact JSON
118+
integers through `2**53 - 1`; native filter strings retain Git's full uint64
119+
range. URL inference is stable across Python versions. Unicode-leading SCP
120+
paths require an explicit VCS. See {ref}`migration`.
121+
122+
#### Migrate checkout targets and backend options (#589)
123+
124+
{ref}`cli-migrate` separates legacy settings into `working_copy`, the
125+
matching backend block, and entry-level pin policy in one pass. Unknown
126+
legacy options stop migration and {ref}`cli-fmt` with exit status `1` before
127+
writing the configuration file. `add` and `discover` write the same layout.
128+
`import` and `fmt` migrate entries they rewrite and preserve entries pinned for
129+
that command. See {ref}`migration` for an upgrade example.
130+
131+
#### Validate shared checkout targets (#589)
132+
133+
`working_copy` and `worktrees` accept the same `branch`, `tag`, `commit`, or
134+
`rev` selector, fetch remote, and `sync` policy. Loading rejects multiple
135+
selectors, unknown keys, and invalid drift or dirty policies, naming the
136+
configuration file, workspace root, repository entry, and field.
137+
48138
### Fixes
49139

50140
#### Separate workspace and repository names in legacy-key warnings (#588)

‎MIGRATION‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,86 @@ well.
2323

2424
<!-- Maintainers, insert changes / features for the next release here -->
2525

26+
### Exact numeric values
27+
28+
Integer configuration fields accept values up to `9007199254740991`
29+
(`2**53 - 1`), so Python and JavaScript editors validate the same values.
30+
For a larger Git filter limit, use a native string such as
31+
`filter: "tree:18446744073709551615"` or a quoted `blob:limit` mapping's
32+
`limit`. These strings retain Git's full uint64 range. Quote large revision
33+
identifiers as strings. Metadata remains ordinary JSON-compatible data.
34+
35+
### Stable URL inference
36+
37+
Backend inference uses ASCII word and digit classes on every supported Python
38+
version. Unprefixed SCP URLs whose path starts with a non-ASCII character,
39+
such as `host:éx`, need `vcs: git` or an explicit `git+ssh://host/éx` URL.
40+
Unicode hostnames and other path characters remain supported. Explicit backend
41+
settings continue to resolve unknown or ambiguous URLs.
42+
43+
### Separate checkout targets and backend options
44+
45+
Run {ref}`cli-migrate` once to move both top-level tuning and the `options`
46+
block into the canonical layout:
47+
48+
```console
49+
$ vcspull migrate --write
50+
```
51+
52+
Before:
53+
54+
```yaml
55+
~/code/:
56+
libvcs:
57+
repo: git+https://github.com/vcs-python/libvcs.git
58+
options:
59+
rev: v0.46.0
60+
depth: 50
61+
pin:
62+
import: true
63+
```
64+
65+
After:
66+
67+
```yaml
68+
~/code/:
69+
libvcs:
70+
repo: git+https://github.com/vcs-python/libvcs.git
71+
working_copy:
72+
rev: v0.46.0
73+
git:
74+
depth: 50
75+
pin:
76+
import: true
77+
```
78+
79+
`shallow: true` becomes `git.depth: 1`. `git_options`, `hg_options`, and
80+
`svn_options` become `git`, `hg`, and `svn`. `pin_reason` and
81+
`allow_overwrite` move from `options` to the entry level alongside `pin`.
82+
Existing canonical values take precedence. Every supplied setting is
83+
validated before precedence applies, including overridden values. Unknown
84+
legacy `options` keys produce an error before the file is written. Remove
85+
invalid values instead of relying on another field to hide them. Both `url`
86+
and `repo` must be valid strings when present; `url` still takes precedence.
87+
Metadata must contain JSON-compatible values with string keys.
88+
89+
`add` and `discover` write the canonical layout. `import` and `fmt` migrate
90+
entries they rewrite; entries pinned for that command stay unchanged. Use
91+
`migrate --write` to upgrade every entry, including pinned entries.
92+
93+
Loading normalizes the same legacy locations in memory and warns once per
94+
file. Unknown entry or backend fields now fail during loading; metadata
95+
belongs in `metadata`, not in a libvcs constructor argument. Sync constructs
96+
the matching immutable libvcs options object from `git`, `hg`, or `svn`.
97+
98+
To omit historical file contents without truncating commit history, add
99+
`git.filter: blob:none`. The value can also be an atomic native filter
100+
string, a kind-tagged mapping, or a nonempty list of filters. Express combined
101+
filters as `{kind: combine, filters: [blob:none, "tree:3"]}` or nested lists;
102+
`vcspull migrate --write` converts native `combine:` strings to that form.
103+
Filter and depth changes only affect a new clone; they do not reconfigure an
104+
existing checkout.
105+
26106
## vcspull 1.62.0 (2026-05-31)
27107

28108
### Per-repository sync keys moved under `options:`

0 commit comments

Comments
 (0)