Skip to content

fix(workspace): make install.sh idempotent for template_project rename (#197) - #201

Merged
c-vigo merged 4 commits into
devfrom
bugfix/197-install-sh-idempotent
Mar 3, 2026
Merged

c-vigo merged 4 commits into
devfrom
bugfix/197-install-sh-idempotent

Conversation

@c-vigo

@c-vigo c-vigo commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Description

Fix install.sh (via init-workspace.sh) to be idempotent when run with --force on an already-initialized workspace. On second run, rsync re-copies src/template_project/ and the mv command moves it inside the existing src/${SHORT_NAME}/ directory, creating a nested src/${SHORT_NAME}/template_project/. The fix guards the rename: if the destination already exists, the redundant copy is removed instead.

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 — Guard the mv src/template_project src/${SHORT_NAME} block: if the destination directory already exists (and SHORT_NAME is not "template_project"), remove the redundant rsync-copied src/template_project instead of moving it inside the existing directory.
  • tests/bats/init-workspace.bats — BATS test verifying the idempotent guard clause exists in the script (checks for the rm -rf branch alongside src/${SHORT_NAME}).
  • CHANGELOG.md — Entry under ## Unreleased / ### Fixed.

Changelog Entry

Fixed

  • install.sh is not idempotent — creates nested src/template_project on second run (#197)
    • Guard template_project rename: if src/${SHORT_NAME} already exists, remove the redundant copy instead of moving it inside

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

N/A — functional testing of init-workspace.sh requires a container environment (covered by integration tests in CI).

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

N/A

Refs: #197

c-vigo and others added 4 commits February 25, 2026 11:31
…t rename

On re-run with --force, rsync re-copies src/template_project/ (since it was
renamed on first run). The mv command then moves it inside the existing
src/${SHORT_NAME}/ directory, creating a nested src/${SHORT_NAME}/template_project/.

Guard the rename: if src/${SHORT_NAME} already exists, remove the redundant
src/template_project instead of moving it.

Refs: #197
Co-authored-by: Cursor <[email protected]>
The single-quoted string is intentional — we check for the literal
${SHORT_NAME} in the script source, not an expansion.

Refs: #197
Co-authored-by: Cursor <[email protected]>
@c-vigo c-vigo self-assigned this Feb 25, 2026
@c-vigo
c-vigo merged commit 850792f into dev Mar 3, 2026
10 checks passed
@c-vigo
c-vigo deleted the bugfix/197-install-sh-idempotent branch March 3, 2026 07:06
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