Repository navigation
fix(init-workspace): preserve dangling store pre-commit symlink - #1124
Merged
Merged
Conversation
A flake-hooks consumer's .pre-commit-config.yaml is a symlink into the host /nix/store, which is not mounted inside the image where init-workspace runs, so the symlink is dangling from the container's view. The preserve/exclude gate, the add/preserve report, and the divergence guard tested presence with -e/-f, which follow the link and reported it absent — so rsync -avL overwrote the symlink with the template config and the #1092 ignore auto-seed never fired. Add a path_present helper (-e || -L) that treats a symlink of any kind as present, and route all three gates through it, so the symlink survives untouched and the ignore seed still runs. Refs: #1117
c-vigo
added a commit
that referenced
this pull request
Jul 15, 2026
…tignore.project (#1129) ## Description The #1092 fix made `.gitignore.project` the durable, preserved home for repo-root ignores, but the upgrade that introduces it seeds it empty: any root ignores a consumer had previously hand-added directly to the managed root `.gitignore` (`.DS_Store`, editor/OS cruft, project paths) were silently dropped when the upgrade regenerated the file from the template. Of the issue's two suggested fixes, this implements the preferred one — **auto-migrate** the consumer's lines into `.gitignore.project` — with the upgrade-note listing as its natural side output. Closes #1111 ## Type of Change - [ ] `feat` -- New feature - [x] `fix` -- Bug fix - [ ] `docs` -- Documentation only - [ ] `chore` -- Maintenance task (deps, config, etc.) - [ ] `refactor` -- Code restructuring (no behavior change) - [ ] `test` -- Adding or updating tests - [ ] `ci` -- CI/CD pipeline changes - [ ] `build` -- Build system or dependency changes - [ ] `revert` -- Reverts a previous commit - [ ] `style` -- Code style (formatting, whitespace) ### Modifiers - [ ] Breaking change (`!`) -- This change breaks backward compatibility ## Changes Made - `assets/init-workspace.sh`: - Snapshot the consumer's old root `.gitignore` before the rsync overwrite (placed with the other pre-overwrite state captures). - New single-responsibility `migrate_root_gitignore()`, called just before `render_gitignore()`: appends to `.gitignore.project` every old-root line that is non-blank, non-comment, not a managed entry (template base + active language fragments + the #1092 seed), and not already in `.gitignore.project`. Append-only (never reorders/rewrites the consumer's existing entries), deduplicated, and idempotent — after the first migration the lines live in `.gitignore.project`, so later upgrades re-add nothing. Prints `Migrated N consumer line(s) into .gitignore.project (#1111):` with the list. - The migrated lines flow into the regenerated root `.gitignore` via `render_gitignore()`'s existing `.gitignore.project` append — no separate write. - `tests/bats/init-workspace.bats`: three regression tests — migrate (lines land in `.gitignore.project` and remain effective in the rendered root `.gitignore`, note printed), idempotence (second upgrade adds nothing), managed-lines-not-migrated. ## Changelog Entry ### Fixed - **Migrate hand-added root `.gitignore` lines into `.gitignore.project` on upgrade** ([#1111](#1111)) - The upgrade that introduced the #1092 `.gitignore.project` seam seeded it empty, silently dropping any root ignores a consumer had hand-added to the managed root `.gitignore` (regenerated from the template every upgrade). - Consumer-added entries (non-blank, non-comment, not template/fragment/seed-managed, not already present) are now migrated append-only into `.gitignore.project` before the render — deduplicated, idempotent across upgrades, with an upgrade note listing what moved. ## Testing - [x] Tests pass locally (`just test`) - [x] Manual testing performed (describe below) ### Manual Testing Details - TDD: all three regression tests committed failing (RED — no migration: note absent, `.DS_Store` missing from `.gitignore.project`), turned GREEN by the fix. - Full `tests/bats/init-workspace.bats`: 204 tests, 0 failures (implementation run + independent review run). - `prek run --all-files`: green (including shellcheck on the new function). ## Checklist - [x] My code follows the project's style guidelines - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly (edit `docs/templates/`, then run `just docs`) - [x] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and pasted the entry above) - [x] My changes generate no new warnings or errors - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] Any dependent changes have been merged and published ## Additional Notes Wave 2 of the commit-action-deployment bug batch, branched after #1124 (same `render_gitignore()` region) merged. Deliberate design choice worth noting: a template example line a consumer *uncommented* (e.g. activating `.idea/`) migrates into `.gitignore.project` — correct data preservation, since their active ignore survives the upgrade. Refs: #1111
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In direnv mode a flake-hooks consumer's
.pre-commit-config.yamlis a symlink into the host/nix/store.install.shrunsinit-workspace.shinside the devcontainer image where that store is not mounted, so the symlink is dangling from the container's viewpoint. The preserve/exclude gate used[[ -e ]](which follows the link), reported the file absent, andrsync -avLwrote the real ~6 KB template over the symlink — which in turn prevented the #1092 ignore auto-seed (its gate is correctly target-based, but the symlink no longer existed when it ran). Net result on every direnv-mode flake-hooks upgrade: a committed, non-ignored template shadowing the flake-generated config. Observed on thevig-os/commit-action1.2.0 → 1.2.1 upgrade (vig-os/commit-action#80).Closes #1117
Type of Change
feat-- New featurefix-- Bug fixdocs-- Documentation onlychore-- Maintenance task (deps, config, etc.)refactor-- Code restructuring (no behavior change)test-- Adding or updating testsci-- CI/CD pipeline changesbuild-- Build system or dependency changesrevert-- Reverts a previous commitstyle-- Code style (formatting, whitespace)Modifiers
!) -- This change breaks backward compatibilityChanges Made
assets/init-workspace.sh: newpath_present()helper ([[ -e || -L ]]— a symlink of any kind, even dangling, is present) routed through all three presence gates:--previewclassification loop (a dangling store symlink now reports PRESERVED, not ADDED),PRECOMMIT_CONFIG_PREEXISTED(was-f; the fix(workspace): scaffold upgrade replaces .pre-commit-config.yaml, silently clobbering repo-specific hook config #878 divergence guard is no longer silently skipped).The [BUG] Managed .gitignore rewrite (#1024) drops consumer-required ignores with no durable committed extension point for repo-root paths #1092 ignore-seed gate itself is unchanged — it was already target-based (
readlink | grep /nix/store/); the fix is that the symlink still exists when it runs.tests/bats/init-workspace.bats: two regression tests reproducing the exact direnv-in-container scenario (dangling/nix/store/...target): symlink survives upgrade untouched + ignore seeded;--previewclassifies PRESERVED. Also updated the existing whitebox exclude-gate assertion that pinned the old literal-eline.Changelog Entry
Fixed
init-workspace.shruns inside the image where the host/nix/storeis not mounted, so a flake-generated.pre-commit-config.yamlsymlink is dangling; the-e/-fpresence gates followed the link, reported it absent, and the template rsync overwrote it — also silencing the [BUG] Managed .gitignore rewrite (#1024) drops consumer-required ignores with no durable committed extension point for repo-root paths #1092 ignore auto-seed.path_present()helper: the symlink survives the copy, the ignore is seeded,--previewclassifies it as PRESERVED, and the fix(workspace): scaffold upgrade replaces .pre-commit-config.yaml, silently clobbering repo-specific hook config #878 divergence guard sees the pre-existing config.Testing
just test)Manual Testing Details
--previewmisclassified as ADDED), turned GREEN by the fix.tests/bats/init-workspace.bats: 200 tests, 0 failures, exit 0 (implementation run + independent review run).prek run --all-files: green.Checklist
docs/templates/, then runjust docs)CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Additional Notes
Part of the commit-action-deployment bug batch. Known adjacent, deliberately not fixed here:
print_preserved_template_diffstill gates on-f, so the #878 divergence diff is not printed for a dangling symlink — harmless (a store symlink has no meaningful template diff and cannot be validated while unmounted). #1111 (root-.gitignoremigration, same function) follows in a separate PR after this one merges.Refs: #1117