Skip to content

Conversation

@tony
Copy link
Member

@tony tony commented Nov 2, 2025

Changes

Improvements

Duplicate-aware config loading

  • load_configs now reuses the duplicate-aware reader so vcspull list,
    status, and sync keep every repository even when workspace roots repeat.

Safer add/discover workflows

  • vcspull add gained a path-first flow that inspects existing checkouts,
    detects the origin remote, shortens paths to ~/…, and confirms before
    writing by default. Use --yes for unattended scripts.
  • vcspull discover mirrors the merge-by-default behavior while offering
    --no-merge for manual review.

Formatter defaults

  • vcspull fmt consolidates duplicate workspace sections automatically and
    surfaces conflicts; --no-merge leaves duplicates in place for inspection.

Documentation

CLI guides and README

  • Updated add/discover/fmt documentation to cover the new merge defaults,
    path-based adds, confirmation flags, and formatter options.
  • Removed the legacy cli/import page now that vcspull add fully replaces the
    old command.

Development

Test coverage

  • Added duplicate-aware loader regression tests and extended CLI fixtures.
  • Formatter scenarios continue to rely on Syrupy
    JSON/YAML snapshots for golden coverage.

Test plan

uv run ruff check . --fix --show-fixes
uv run ruff format .
uv run mypy
uv run py.test

@codecov
Copy link

codecov bot commented Nov 2, 2025

Codecov Report

❌ Patch coverage is 78.04878% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.82%. Comparing base (9de7877) to head (cf8813f).
⚠️ Report is 21 commits behind head on master.

Files with missing lines Patch % Lines
src/vcspull/cli/add.py 72.64% 20 Missing and 9 partials ⚠️
src/vcspull/config.py 72.91% 7 Missing and 6 partials ⚠️
src/vcspull/cli/discover.py 75.86% 3 Missing and 4 partials ⚠️
src/vcspull/_internal/config_reader.py 93.33% 3 Missing and 1 partial ⚠️
src/vcspull/cli/fmt.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #480      +/-   ##
==========================================
+ Coverage   78.70%   78.82%   +0.12%     
==========================================
  Files          13       13              
  Lines        1592     1738     +146     
  Branches      341      369      +28     
==========================================
+ Hits         1253     1370     +117     
- Misses        213      232      +19     
- Partials      126      136      +10     

☔ View full report in Codecov by Sentry.
📢 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.

@tony tony force-pushed the add-refactor branch 5 times, most recently from f748d83 to 30d03f4 Compare November 2, 2025 15:42
tony added 20 commits November 2, 2025 11:12
why: The add_from_fs CLI module was removed, so our logger propagation test should no longer expect that logger.

what:
- drop the add_from_fs logger name from the propagation assertions
- leave the remaining CLI logger checks intact so coverage stays the same
why: ConfigReader still loses duplicate workspace roots while the new formatter
keeps them, and we need to track the follow-up work.

what:
- document the divergence with fmt’s loader in a TODO block
- outline options for sharing or replacing the loader once the new add flow lands
  config/reader(chore[todo]): plan duplicate-aware loader alignment
why: Loading configs with duplicate workspace roots dropped earlier entries,
causing data loss when commands rewrote the file.

what:
- introduce DuplicateAwareConfigReader that records duplicate top-level keys
  using a SafeLoader hook
- expose helpers to return both the parsed config and duplicate occurrences for
  downstream merging
why: The new loader needs regression tests to ensure duplicates are tracked for
YAML and ignored for JSON.

what:
- add fixtures that capture duplicate YAML sections and confirm both entries are
  recorded
- cover non-duplicate YAML and JSON inputs to prove the loader behaves like the
  legacy path otherwise
why: fmt already had bespoke duplicate-merging logic; now that we have a shared
loader we can drop the custom YAML plumbing.

what:
- add reusable merge helpers in vcspull.config
- switch fmt to DuplicateAwareConfigReader.load_with_duplicates and the shared
  merge helpers
- remove the local SafeLoader subclass and copy helpers
why: Users expect `vcspull add <path>` to detect a repo name/remote and confirm
before writing, but the command only supported name + URL.

what:
- replace the positional arguments with `target` plus optional URL and support
  `--name`
- detect git remotes for path inputs, fall back to local path, and prompt (with
  `--yes` support) before writing
- reuse duplicate-aware loading/merge helpers so path imports don’t drop
  existing workspace entries
why: The new path-first add flow needs regression tests for dry-run,
confirmation, and duplicate scenarios.

what:
- add parametrized fixtures for auto-confirm, interactive accept/decline,
  no-remote, and no-merge cases
- normalize log output and assert config contents to match the new behavior
why: The changelog should mention the path-based add enhancements delivered in
this series.

what:
- document the duplicate-aware loading, path detection, and confirmation changes
  under Improvements
why: Some workflows want to inspect duplicate roots without auto-merging;
add/discover always merged, risking unintended writes.

what:
- add a shared `--no-merge` flag that skips automatic merging while still logging
  warnings for duplicates
- thread the optional merge behavior through add_repo and discover_repos using
  the duplicate-aware loader helpers
- keep merge-on as the default so existing behavior stays intact
why: The new `--no-merge` flag must be regression-tested for both add and discover commands.

what:
- extend the CLI test suites with merge/no-merge parametrized fixtures
- normalize log output and verify config contents when duplicates are kept
  separate
why: Merge/no-merge flows change CLI logs; snapshots need to reflect the new
output.

what:
- record Syrupy snapshots for the updated add path-mode cases
- add a discover snapshot covering the no-merge warning messaging
why: Document the new flag so users spot the opt-out quickly.
what:
- mention the shared --no-merge switch in the improvements section
why: Commands using load_configs were still dropping earlier workspace-root
entries, so duplicate paths silently lost repositories outside fmt/add/discover.

what:
- load configs through DuplicateAwareConfigReader and merge duplicates by
  default while logging conflicts or skipped merges
- keep an opt-out via merge_duplicates=False for callers that want legacy
  behavior
- add regression tests ensuring both paths keep expected repos and emit logs
why: Users reading the changelog need to know list/status/sync now benefit from
the duplicate-aware loader introduced for fmt/add/discover.

what:
- highlight that load_configs merges duplicate workspace roots by default so CLI
  reads no longer drop repositories
- document the merge_duplicates opt-out for workflows that still need the
  previous "last occurrence wins" semantics
why: Chained string literals are harder to read/update than a single YAML block
when crafting duplicate-root fixtures.

what:
- build the duplicate workspace config with a triple-quoted string via
  textwrap.dedent for clarity
- import textwrap alongside existing logging dependency
why: Several fixtures still built config blobs from chained string literals,
which are harder to tweak than a single dedented block.

what:
- use textwrap.dedent triple-quoted strings for duplicate-root YAML and JSON in
  test_config_reader
- switch the vcspull add duplicate-root fixture to the same style and import
  textwrap alongside existing helpers
why: The previous changelog entry listed internal implementation details; users
need a product-level summary of what happens by default and the flags available.

what:
- reword the `vcspull add`, `discover`, and loader sections to describe user
  experience, default behavior, and opt-outs in plain language
- keep existing section structure while aligning phrasing with the rest of the
  release notes
why: The fmt and formatter-test entries still read like implementation notes; we
want product-level phrasing consistent with the rest of the changelog.

what:
- explain that `vcspull fmt` now merges duplicate workspace sections by default
  and point to `--no-merge` for inspection-only runs
- describe Syrupy snapshot coverage as a guardrail for future fmt changes
why: User-facing docs and README still describe the pre-merge behavior for add,
discover, and fmt; guidance should mention the new defaults without drowning out
other tips.

what:
- note that fmt merges duplicate workspace roots unless --no-merge is supplied
- explain path-based adds, confirmation flags, and duplicate handling in
  docs/cli/add.md and the README bullet list
- mention discover's default merge behavior with a concise pointer to
  --no-merge
@tony tony merged commit b36ef98 into master Nov 2, 2025
9 checks passed
tony added a commit that referenced this pull request Nov 4, 2025
why: path-first workflow should not create stray ./ workspaces.
what:
- always prefer tilde labels unless CLI requests ./ explicitly
- write duplicate sections using ordered loader items without config_items
- expand CLI coverage for dot workspace scenarios

refs: #483, #482, #481, #480
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.

2 participants