Skip to content

fix(workspace): upgrade preview report follows template symlinks (#949) - #950

Merged
c-vigo merged 2 commits into
release/0.5.0from
bugfix/949-preview-report-follows-symlinks
Jul 9, 2026
Merged

c-vigo merged 2 commits into
release/0.5.0from
bugfix/949-preview-report-follows-symlinks

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Problem

On the Nix image the baked template /root/assets/workspace is a tree of symlinks into the nix store. The --preview/--force upgrade classifier at assets/init-workspace.sh:534 walked it with find "$TEMPLATE_DIR" -type f …, which matches zero files against a symlink tree (verified: find -type f → 0, find -L -type f → 1872). So the OVERWRITTEN / ADDED / PRESERVED report was always empty ("No existing files would be overwritten").

Root cause

The real copy uses rsync -avL, which follows symlinks, so files were still overwritten — only the report was blind. The DELETED section is computed separately and was unaffected. This is the sole find over $TEMPLATE_DIR.

Fix

Make the classifier follow symlinks to match the copy semantics:

-    done < <(find "$TEMPLATE_DIR" -type f ! -path "*/.git/*" -print0)
+    done < <(find -L "$TEMPLATE_DIR" -type f ! -path "*/.git/*" -print0)

Tests (TDD, red → green)

Added two bats tests in tests/bats/init-workspace.bats that seed a symlinked TEMPLATE_DIR (mirroring the baked image) and drive --preview --force --no-prompts against a host workspace:

  • a symlinked template file whose path already exists in the workspace must be listed under OVERWRITTEN;
  • a symlinked, workspace-absent template file must be listed under ADDED.

Both failed on the old code (report said "No existing files would be overwritten" / "No new files would be added") and pass with the fix. Full init-workspace.bats suite: 123 passed, 0 failed. Full prek run --all-files hook suite: green (sync-manifest propagated the CHANGELOG entry to the scaffold copy).

Refs: #949
Closes #949

c-vigo added 2 commits July 9, 2026 08:08
The Nix image bakes assets/workspace as symlinks into the nix store, so
the --preview/--force classifier's find -type f matched zero files and the
OVERWRITTEN/ADDED report was always empty. Add bats coverage that seeds a
symlinked TEMPLATE_DIR and asserts a conflicting file lands under
OVERWRITTEN and a workspace-absent one under ADDED.

Refs: #949
On the Nix image the baked template /root/assets/workspace is a tree of
symlinks into the nix store, so the --preview/--force classifier's
find -type f matched zero files and the OVERWRITTEN/ADDED report was always
empty. The real copy uses rsync -avL (follows symlinks), so only the report
was blind. Add -L so the classifier dereferences symlinks and matches the
copy semantics.

Refs: #949
@c-vigo
c-vigo enabled auto-merge July 9, 2026 06:16
@c-vigo

c-vigo commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed the diff: the fix is the single-site find → find -L at init-workspace.sh:534 (matches the rsync -avL copy semantics); the added bats tests build store-style ln -s symlinks in TEMPLATE_DIR and assert OVERWRITTEN/ADDED are populated, genuinely reproducing #949 (red→green); changelog entry correctly under ## [0.5.0] - TBD → Fixed. Minimal, in-scope, TDD-clean. LGTM — auto-merge stands.

@c-vigo
c-vigo merged commit 1eacba6 into release/0.5.0 Jul 9, 2026
13 checks passed
@c-vigo
c-vigo deleted the bugfix/949-preview-report-follows-symlinks branch July 9, 2026 06:25
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