Skip to content

Commit af6e402

Browse files
committed
config,cli(fix,docs): Exit 1 on invalid fmt and align canonical docs
why: vcspull fmt exited 0 when migrate_repo_entry() rejected an invalid option, testing/typings omitted schema packages, and docs/examples still showed legacy options.pin blocks. what: - Return non-zero status from format_config_file() and raise SystemExit in cli() - Add pydantic/jsonschema to testing and types-jsonschema to typings - Update docs, examples, types, and schema hover strings to canonical pin and working_copy blocks - Convert schema agreement test cases to NamedTuple fixtures
1 parent 2011f62 commit af6e402

15 files changed

Lines changed: 410 additions & 176 deletions

File tree

‎docs/_static/schemas/vcspull.schema.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@
252252
"description": "Serialized repository entry; either ``repo`` or ``url`` is required.\n\n``url`` takes precedence when both are present. Backend blocks match the\ninferred or declared VCS. Legacy keys remain available for migration.",
253253
"properties": {
254254
"repo": {
255-
"description": "Repository URL; `url` wins when both aliases are supplied.",
255+
"description": "Repository URL; ``url`` wins when both aliases are supplied.",
256256
"type": "string",
257257
"pattern": "^[^\\u0000]*(?![\\s\\S])",
258258
"minLength": 1
259259
},
260260
"url": {
261-
"description": "Alternate repository URL, taking precedence over `repo`.",
261+
"description": "Alternate repository URL, taking precedence over ``repo``.",
262262
"type": "string",
263263
"pattern": "^[^\\u0000]*(?![\\s\\S])",
264264
"minLength": 1

‎docs/cli/add.md‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,8 @@ Repositories whose configuration includes a {ref}`pin <config-pin>` on the
236236
~/code/:
237237
internal-fork:
238238
repo: "git+git@github.com:myorg/internal-fork.git"
239-
options:
240-
pin: true
241-
pin_reason: "pinned to company fork — update manually"
239+
pin: true
240+
pin_reason: "pinned to company fork — update manually"
242241
```
243242
244243
Attempting to add a repo that matches an existing pinned entry previews it as
@@ -257,7 +256,7 @@ Repository 'internal-fork' is pinned (pinned to company fork — update manually
257256
The pin is checked when the entry is written, not when the preview is built, so
258257
confirming still reaches the warning rather than skipping the prompt.
259258

260-
Both `options.pin: true` (global) and `options.pin.add: true` (per-operation)
259+
Both `pin: true` (global) and `pin.add: true` (per-operation)
261260
block the `add` command. The `pin_reason` (if set) is included in the warning.
262261
See {ref}`config-pin` for full pin configuration.
263262

‎docs/cli/discover.md‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,9 @@ scanning. For example, given this configuration:
238238
~/code/:
239239
internal-fork:
240240
repo: "git+git@github.com:myorg/internal-fork.git"
241-
options:
242-
pin:
243-
discover: true
244-
pin_reason: "pinned to company fork — update manually"
241+
pin:
242+
discover: true
243+
pin_reason: "pinned to company fork — update manually"
245244
```
246245
247246
When `vcspull discover` encounters `internal-fork` on disk, it groups it with
@@ -254,7 +253,7 @@ $ vcspull --log-level debug discover ~/code \
254253
--recursive
255254
```
256255

257-
Both `options.pin: true` (global) and `options.pin.discover: true`
256+
Both `pin: true` (global) and `pin.discover: true`
258257
(per-operation) block discovery. See {ref}`config-pin` for full pin
259258
configuration.
260259

‎docs/cli/fmt.md‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ given this configuration:
4242
~/code/:
4343
pinned-dep:
4444
url: git+https://corp.example.com/team/pinned-dep.git
45-
options:
46-
pin:
47-
fmt: true
45+
pin:
46+
fmt: true
4847
libvcs: git+https://github.com/vcspull/libvcs.git
4948
```
5049
@@ -57,9 +56,8 @@ keeps its original `url` key and field order:
5756
repo: git+https://github.com/vcspull/libvcs.git
5857
pinned-dep:
5958
url: git+https://corp.example.com/team/pinned-dep.git
60-
options:
61-
pin:
62-
fmt: true
59+
pin:
60+
fmt: true
6361
```
6462

6563
See {ref}`config-pin` for full pin configuration.

‎docs/cli/import/index.md‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,9 @@ Repositories protected by a pin are **exempt** from both URL updates and
378378
pruning. The following configurations all prevent `--sync` from modifying
379379
an entry:
380380

381-
- `options.pin: true` — blocks all operations
382-
- `options.pin.import: true` — blocks import only
383-
- `options.allow_overwrite: false` — shorthand for `pin: {import: true}`
381+
- `pin: true` — blocks all operations
382+
- `pin.import: true` — blocks import only
383+
- `allow_overwrite: false` — shorthand for `pin: {import: true}`
384384

385385
Pinned repositories are skipped with an informational message showing the
386386
`pin_reason` (if set):
@@ -406,10 +406,9 @@ For example, this entry cannot be updated or pruned regardless of `--sync`:
406406
~/code/:
407407
internal-fork:
408408
repo: "git+ssh://git@corp.example.com/team/internal-fork.git"
409-
options:
410-
pin:
411-
import: true
412-
pin_reason: "pinned to company mirror — update manually"
409+
pin:
410+
import: true
411+
pin_reason: "pinned to company mirror — update manually"
413412
```
414413

415414
See {ref}`config-pin` for full pin configuration.

‎docs/cli/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
:::{grid-item-card} Migrate
5353
:link: migrate
5454
:link-type: doc
55-
{ref}`vcspull migrate <cli-migrate>` moves sync options under `options:`.
55+
{ref}`vcspull migrate <cli-migrate>` rewrites legacy options into canonical blocks.
5656
:::
5757

5858
:::{grid-item-card} Import

‎docs/configuration/index.md‎

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ Integer configuration fields use the exact JSON integer range through
7474
`9007199254740991`. Native Git filter strings retain the full uint64 range;
7575
for example, `filter: "tree:18446744073709551615"`.
7676
77-
```yaml
78-
~/workdir/:
79-
repo_name:
80-
remotes:
81-
origin: git_repo_url
82-
```
83-
8477
### Examples
8578
8679
````{tab} Simple
@@ -127,21 +120,55 @@ YAML:
127120
128121
````
129122

123+
## Checkout targets
124+
125+
Declare the main checkout's target and synchronization policy under
126+
`working_copy`. When omitted, synchronization follows the repository's current
127+
branch with `drift: follow` and `dirty: abort`.
128+
129+
```yaml
130+
~/code/:
131+
flask:
132+
repo: git+https://github.com/pallets/flask.git
133+
remotes:
134+
upstream:
135+
fetch_url: git+https://github.com/pallets/flask.git
136+
push_url: git+ssh://git@github.com/me/flask.git
137+
working_copy:
138+
branch: main
139+
remote: upstream
140+
sync:
141+
drift: follow
142+
dirty: preserve
143+
```
144+
145+
Each `working_copy` mapping selects **one** target (`branch`, `tag`, `commit`,
146+
or `rev`), with optional `remote` (fetch alias, separate from push URLs) and
147+
`sync`:
148+
149+
- `sync.drift`: `follow` (default), `keep`, or `warn`
150+
- `sync.dirty`: `abort` (default), `preserve`, or `discard` (requires `--yes`
151+
on every CLI run)
152+
130153
## Worktree configuration
131154

132155
Repositories can declare worktrees—additional checkouts of specific tags,
133-
branches, or commits in separate directories. Worktrees are listed under the
134-
`worktrees` key of a repository entry:
156+
branches, commits, or revisions in separate directories. Worktrees are listed
157+
under the `worktrees` key of a repository entry:
135158

136159
```{literalinclude} ../../examples/worktrees.yaml
137160
:language: yaml
138161
```
139162

140163
Each worktree entry requires:
141164
- `dir`: Path for the worktree (relative to workspace root or absolute)
142-
- Exactly one of `tag`, `branch`, or `commit`
165+
- Exactly one of `tag`, `branch`, `commit`, or `rev`
143166

144167
Optional fields:
168+
- `remote`: Fetch remote alias for branch targets
169+
- `detach`: Keep branch targets detached (`true` or `false`)
170+
- `sync`: Per-worktree `drift` (`follow`, `keep`, `warn`) and `dirty`
171+
(`abort`, `preserve`, `discard`) policy
145172
- `lock`: Lock the worktree to prevent accidental removal
146173
- `lock_reason`: Reason for locking (implies `lock: true`)
147174

‎examples/christmas-tree.yaml‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,16 @@
1919
# Global pin — no automated command can modify this entry
2020
internal-fork:
2121
repo: git+git@github.com:myorg/internal-fork.git
22-
options:
23-
pin: true
24-
pin_reason: "pinned to company fork — update manually"
22+
pin: true
23+
pin_reason: "pinned to company fork — update manually"
2524
# Per-operation pin — only import and fmt are blocked
2625
my-framework:
2726
repo: git+git@github.com:myorg/my-framework.git
28-
options:
29-
pin:
30-
import: true
31-
fmt: true
32-
pin_reason: "URL managed manually; formatting intentional"
27+
pin:
28+
import: true
29+
fmt: true
30+
pin_reason: "URL managed manually; formatting intentional"
3331
# Shorthand — equivalent to pin: {import: true}
3432
stable-dep:
3533
repo: git+https://github.com/upstream/stable-dep.git
36-
options:
37-
allow_overwrite: false
34+
allow_overwrite: false

‎pyproject.toml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ testing = [
116116
"pytest-rerunfailures",
117117
"pytest-mock",
118118
"pytest-watcher",
119+
"pydantic>=2.13.5",
120+
"jsonschema>=4.26.0",
119121
]
120122
coverage =[
121123
"codecov",
@@ -131,13 +133,15 @@ typings = [
131133
"types-Pygments",
132134
"types-requests",
133135
"types-PyYAML",
134-
"types-colorama"
136+
"types-colorama",
137+
"types-jsonschema>=4.26.0.20260518",
135138
]
136139

137140
[build-system]
138141
requires = ["hatchling"]
139142
build-backend = "hatchling.build"
140143

144+
141145
[tool.uv.exclude-newer-package]
142146
# vcspull's release cadence is tightly coupled to libvcs -- a libvcs
143147
# release blocking on a 3-day cooldown blocks every contributor's

‎src/vcspull/cli/__init__.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,14 @@ def cli(_args: list[str] | None = None) -> None:
598598
depth=getattr(args, "depth", None),
599599
)
600600
elif args.subparser_name == "fmt":
601-
format_config_file(
601+
result = format_config_file(
602602
args.config,
603603
args.write,
604604
args.all,
605605
merge_roots=args.merge_roots,
606606
)
607+
if result:
608+
raise SystemExit(result)
607609
elif args.subparser_name == "migrate":
608610
result = migrate_config_file(
609611
args.config,

0 commit comments

Comments
 (0)