feat: Centralized config output style system with --style flag#516
feat: Centralized config output style system with --style flag#516tony wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #516 +/- ##
==========================================
+ Coverage 83.30% 83.36% +0.06%
==========================================
Files 32 34 +2
Lines 4492 4647 +155
Branches 903 937 +34
==========================================
+ Hits 3742 3874 +132
- Misses 499 515 +16
- Partials 251 258 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
db913f7 to
0967b56
Compare
|
Re-authored on current Landed: the flagship Deferred: styling newly-added entries in |
why: Centralize the three config output styles (concise, standard, verbose) as a typed enum so all commands share the same vocabulary. what: - Add ConfigStyle enum with CONCISE, STANDARD, VERBOSE values - Add RawRepoEntry TypeAlias (str | dict[str, Any])
why: All commands that write config entries (add, discover, import, fmt)
were independently hardcoding {"repo": url}. A central module enables
consistent output and bidirectional style conversion.
what:
- Add format_repo_entry() for creating new entries in any style
- Add restyle_repo_entry() for converting existing entries between styles
- Add apply_config_style() for bulk-transforming full config dicts
- Add helpers: _infer_vcs_from_url, _strip_vcs_prefix, _read_git_remotes,
_extract_url, _has_extra_keys
- Lossy verbose→concise conversions warn and preserve original entry
- Add 38 parametrized tests with syrupy snapshots
why: Allow users to set a default config_style in settings.toml so they don't need to pass --style on every command invocation. what: - Add settings.toml loader using tomllib (3.11+) with tomli fallback - Add VcspullSettings dataclass with config_style field - Add resolve_style() for CLI-flag-overrides-settings priority chain - Add tomli>=1.0 conditional dependency for Python <3.11 - Add 11 tests covering TOML parsing, fallbacks, and resolution
why: fmt could only normalize toward the standard dict-with-repo-key
form. With the central config-style formatter now in place, fmt can
convert entries to concise (bare URL string) or verbose (full dict with
remotes) as well, letting users pick a house style for their config.
what:
- Add --style {concise,standard,verbose} to create_fmt_subparser
- Thread the style through format_config_file -> format_single_config ->
format_config; the latter calls apply_config_style after sorting and
surfaces lossy-conversion warnings
- Resolve the flag via settings.resolve_style at the CLI boundary,
restyling only when --style is passed (keeps save_config, not
save_config_yaml)
- Cover the conversion with a parametrized format_config test
why: The --style restyling and the ConfigStyle system are user-facing additions for the next release and need a What's new entry. what: - Add a What's new entry describing vcspull fmt --style and the ConfigStyle output styles under the v1.66.x block
Summary
flask: "git+url"), standard (flask: {repo: "git+url"}), and verbose (flask: {repo: url, vcs: git, remotes: {...}})--styleCLI flag tofmt,add,discover, andimportcommands, with asettings.tomlfile for persistent defaults{"repo": url}entry creation across four command families with a singleformat_repo_entry()APIThree config styles
flask: "git+https://..."strflask: {repo: "git+https://..."}dict(repo key only)flask: {repo: "git+url", vcs: "git", remotes: {origin: "..."}}dict(repo + vcs + remotes)Default: standard (preserves current behavior — no breaking changes).
New files
src/vcspull/_internal/config_style.pyformat_repo_entry(),restyle_repo_entry(),apply_config_style()+ helperssrc/vcspull/_internal/settings.pysettings.tomlloader withload_settings()/resolve_style()tests/_internal/test_config_style.pytests/_internal/test_settings.pyKey design decisions
extract_repos()andvalidator.pyalready handle all three input forms; no changes needed there--styleis explicitly passed orsettings.tomlis created--styleflag beatssettings.tomlbeats the built-in defaultCommits (7 atomic)
feat(types[ConfigStyle])— enum + type aliasfeat(_internal[config_style])— central formatting module + testsfeat(_internal[settings])— TOML settings + tomli dep + testsfeat(cli/fmt[style])—--styleflag for bidirectional restylingfeat(cli/add[style])—format_repo_entry()with--stylefeat(cli/discover[style])—format_repo_entry()with--style+ cli dispatchfeat(cli/import[style])—format_repo_entry()with--styleacross 6 service handlersTest plan
uv run ruff check .cleanuv run ruff format --check .cleanuv run mypyclean (0 errors in 92 source files)vcspull fmt --style concise --writeconverts dict entries to stringsvcspull fmt --style verbose --writeconverts string entries to dicts with remotesvcspull add ./some-repo --style concisewrites string entryvcspull discover ~/code --style verbose --dry-runshows verbose entries~/.config/vcspull/settings.tomlwithconfig_style = "concise", verify default