Skip to content

cli/fmt(feat[style]): Add config output styles and fmt --style - #516

Open
tony wants to merge 6 commits into
masterfrom
output-styles
Open

tony wants to merge 6 commits into
masterfrom
output-styles

Conversation

@tony

@tony tony commented Feb 15, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add a config output style system with three named styles: concise (flask: git+url), standard (flask: {repo: git+url}), and verbose (flask: {remotes: {...}, repo: git+url, vcs: git})
  • Add --style {concise,standard,verbose} to vcspull fmt for bidirectional restyling across styles, reading local Git remotes on disk when expanding to verbose
  • Provide ConfigStyle, format_repo_entry(), restyle_repo_entry(), and apply_config_style() in vcspull._internal.config_style, omitting remotes on Subversion entries and preserving custom configuration blocks across round-trips

Refs #592

Three config styles

Style YAML example Python type
concise flask: git+https://... str
standard flask: {repo: git+https://...} dict (repo key, plus any custom blocks)
verbose flask: {remotes: {origin: ...}, repo: git+url, vcs: git} dict (repo + vcs, plus remotes on Git/Hg)

Default behavior when --style is omitted matches standard normalization with no breaking changes.

Before and after

Before (standard):

~/code/:
  flask:
    repo: git+https://github.com/pallets/flask.git

After vcspull fmt --style concise --write:

~/code/:
  flask: git+https://github.com/pallets/flask.git

After vcspull fmt --style verbose --write:

~/code/:
  flask:
    remotes:
      origin: https://github.com/pallets/flask.git
    repo: git+https://github.com/pallets/flask.git
    vcs: git

Key design decisions

  1. Keep style handling on the output side because extract_repos() and validator.py already accept all three input forms.
  2. Strip redundant vcs keys and single-origin remotes matching the primary URL when restyling to standard or concise, while warning in concise and preserving entries that carry custom blocks, split push/fetch URLs, extra remotes, or an explicit vcs on an unprefixed URL.
  3. Run restyling only when --style is passed so plain vcspull fmt and pinned entries keep their existing behavior.
  4. Read local Git remotes via resolved workspace base_dirs when expanding to verbose, and omit remotes on Subversion entries.

Changes

  • Add ConfigStyle (concise, standard, verbose) and RawRepoEntry in src/vcspull/types.py
  • Add format_repo_entry(), restyle_repo_entry(), and apply_config_style() in src/vcspull/_internal/config_style.py
  • Add --style {concise,standard,verbose} to vcspull fmt in src/vcspull/cli/fmt.py and src/vcspull/cli/__init__.py, threading resolved workspace base_dirs for local Git remote discovery
  • Document vcspull fmt --style in docs/cli/fmt.md and CHANGES
  • Add unit, CLI round-trip, and snapshot coverage in tests/_internal/test_config_style.py and tests/cli/test_fmt.py

Test plan

  • Verify uv run py.test covers bidirectional concise / standard / verbose round-trips, custom-block preservation, local Git remote discovery, and Subversion remotes omission
  • Verify uv run ruff check ., uv run ruff format --check ., and uv run mypy . pass on the style types and CLI plumbing
  • Verify uv run python scripts/generate_schema.py --check confirms configuration schema agreement
  • Verify just build-docs builds docs/cli/fmt.md and CHANGES with zero cross-reference warnings
  • Run vcspull fmt --style concise --write, vcspull fmt --style verbose --write, and vcspull fmt --style standard --write against a sample config to confirm clean round-tripping

@codecov

codecov Bot commented Feb 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.51%. Comparing base (56dc1f3) to head (1d3e5c0).

Files with missing lines Patch % Lines
src/vcspull/_internal/config_style.py 86.11% 12 Missing and 8 partials ⚠️
src/vcspull/cli/fmt.py 92.30% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #516      +/-   ##
==========================================
+ Coverage   84.38%   84.51%   +0.13%     
==========================================
  Files          37       38       +1     
  Lines        5969     6142     +173     
  Branches     1184     1235      +51     
==========================================
+ Hits         5037     5191     +154     
- Misses        634      646      +12     
- Partials      298      305       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from scraper to master February 15, 2026 15:10
@tony
tony force-pushed the output-styles branch 2 times, most recently from db913f7 to 0967b56 Compare February 16, 2026 01:32
@tony
tony force-pushed the output-styles branch from 0967b56 to cf09c87 Compare July 5, 2026 14:51
@tony

tony commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

Re-authored on current master. The three infrastructure commits (ConfigStyle/RawRepoEntry types, the central config_style formatter, and the settings loader with their tests) cherry-picked cleanly. The CLI wiring was rebuilt against master's current handlers rather than the stale versions the branch carried.

Landed: the flagship vcspull fmt --style {concise,standard,verbose}, threaded through format_config_file → format_single_config → format_config onto master's _classify_fmt_action flow (keeping save_config, not the branch's save_config_yaml). Restyling fires only on an explicit --style, so plain vcspull fmt is unchanged.

Deferred: styling newly-added entries in add/discover/import. Those handlers were each rebuilt around pinning (build_repo_entry, the _classify_* action enums, --prune-untracked) since this branch was authored, so wiring format_repo_entry into them is a separate, larger integration best done as a focused follow-up now that the ConfigStyle/config_style/settings infrastructure is in place. The full gate (ruff/mypy/pytest/build-docs) is green.

@tony
tony force-pushed the output-styles branch from cf09c87 to 472746a Compare July 5, 2026 15:00
@tony

tony commented Aug 22, 2026

Copy link
Copy Markdown
Member Author

Automated review finding. Recorded here so it is not lost. Nothing has been pushed to this branch and no fix is applied — this is a note, not a change request.

settings.toml's config_style never takes effect

src/vcspull/cli/__init__.py calls resolve_style(args.style) if args.style else None. When --style is omitted the call is skipped entirely and style becomes None — but resolve_style() was written specifically to handle cli_style=None by falling back to settings.

Failure scenario: a user sets config_style = "verbose" in settings.toml; plain vcspull fmt --write never restyles to verbose. That contradicts the CLI > settings.toml > default precedence this PR documents.

Suggested fix: call resolve_style(args.style) unconditionally and let it apply the fallback it already implements.

@tony tony mentioned this pull request Nov 28, 2026
13 of 25 tasks
tony added a commit that referenced this pull request Nov 29, 2026
why: Document vcspull fmt --style behavior in the CLI reference and
record the v1.70.x What's new changelog entry.

what:
- Add an Output styles section with examples to docs/cli/fmt.md
- Add a What's new entry for vcspull fmt --style (#516) in CHANGES
@tony tony changed the title feat: Centralized config output style system with --style flag cli/fmt(feat[style]): Add config output styles and fmt --style Nov 29, 2026
tony added a commit that referenced this pull request Nov 29, 2026
why: Document vcspull fmt --style behavior in the CLI reference and
record the v1.70.x What's new changelog entry.

what:
- Add an Output styles section with examples to docs/cli/fmt.md
- Add a What's new entry for vcspull fmt --style (#516) in CHANGES
tony added 6 commits November 29, 2026 13:46
why: Centralize the three repository entry output styles (concise,
standard, verbose) in a shared enum and type alias for formatting APIs.

what:
- Add ConfigStyle enum with CONCISE, STANDARD, and VERBOSE members
- Add RawRepoEntry type alias for serialized string or mapping entries
why: Provide bidirectional conversion across concise, standard, and
verbose repository entry formats without discarding extra blocks or
emitting invalid backend keys.

what:
- Add format_repo_entry, restyle_repo_entry, and apply_config_style
- Strip redundant vcs and single-origin remotes when restyling back to
  standard or concise while keeping load-bearing vcs, custom remotes,
  and extra blocks intact
- Omit remotes on Subversion entries so libvcs SvnSync construction
  succeeds
- Require a direct .git entry in _read_git_remotes so uncloned paths
  inside an enclosing checkout do not inherit parent remotes
- Add unit, round-trip, and snapshot tests for config_style
why: Let vcspull fmt convert repository entries between concise,
standard, and verbose styles on demand while keeping plain vcspull fmt
and pinned entries unchanged.

what:
- Add --style {concise,standard,verbose} to create_fmt_subparser and
  thread ConfigStyle through cli, format_config_file,
  format_single_config, and format_config
- Pass resolved workspace base_dirs into format_config and
  apply_config_style so --style verbose reads remotes from local Git
  checkouts on disk
- Cover CLI round-tripping, Subversion sync backend construction, local
  Git remote discovery, and pinned/lossy entry preservation
why: Document vcspull fmt --style behavior in the CLI reference and
record the v1.70.x What's new changelog entry.

what:
- Add an Output styles section with examples to docs/cli/fmt.md
- Add a What's new entry for vcspull fmt --style (#516) in CHANGES
why: Document the new --style option on vcspull fmt and ConfigStyle
forms for users upgrading workspaces.

what:
- Describe concise, standard, and verbose entry formatting under What's
  new
… TypeVars

why: _is_redundant_remotes returned an unsound Unknown | Literal[False]
union under ty when comparing unnarrowed Mapping values, and RawRepoEntry,
config_style, and fmt style tests used Any or object where YamlValue,
RepoEntryDict, and Mapping TypeVars express the contracts.

what:
- Add YamlScalar and YamlValue in vcspull.types and narrow RawRepoEntry
  to str | dict[str, YamlValue]
- Parameterize config_style helpers over Mapping value TypeVars and
  narrow origin fetch_url/push_url to str before comparing
- Narrow unpinned workspace entries in cli/fmt.py and style fixtures in
  tests/_internal/test_config_style.py and tests/cli/test_fmt.py

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant