Skip to content

fix(init-workspace): migrate hand-added root gitignore lines into .gitignore.project - #1129

Merged
c-vigo merged 4 commits into
devfrom
bugfix/1111-migrate-root-gitignores
Jul 15, 2026
Merged

c-vigo merged 4 commits into
devfrom
bugfix/1111-migrate-root-gitignores

Conversation

@c-vigo

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

Copy link
Copy Markdown
Contributor

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
  • 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 [BUG] Managed .gitignore rewrite (#1024) drops consumer-required ignores with no durable committed extension point for repo-root paths #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

Testing

  • Tests pass locally (just test)
  • 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

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • 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

@c-vigo c-vigo self-assigned this Jul 15, 2026
@c-vigo
c-vigo merged commit 1ecb871 into dev Jul 15, 2026
13 checks passed
@c-vigo
c-vigo deleted the bugfix/1111-migrate-root-gitignores branch July 15, 2026 14:57
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