Skip to content

Comments

feat: create .gitignore during repo upgrade if missing#409

Merged
stack72 merged 1 commit intomainfrom
feat/repo-upgrade-gitignore
Feb 20, 2026
Merged

feat: create .gitignore during repo upgrade if missing#409
stack72 merged 1 commit intomainfrom
feat/repo-upgrade-gitignore

Conversation

@stack72
Copy link
Contributor

@stack72 stack72 commented Feb 20, 2026

Summary

swamp repo upgrade did not check for or create a .gitignore file, unlike swamp repo init which calls createGitignoreIfNotExists. This meant repos initialised before gitignore support was added, or repos where the file was accidentally deleted, would not get a .gitignore on upgrade.

This PR mirrors the same create-if-not-exists pattern already used for the instructions file during upgrade.

Changes

src/domain/repo/repo_service.ts

  • Added gitignoreCreated: boolean to the RepoUpgradeResult interface.
  • Called createGitignoreIfNotExists(repoPath, tool) inside upgrade() after the Claude-settings block, before the return statement.
  • Included gitignoreCreated in the return value.

src/presentation/output/repo_output.ts

  • Added gitignoreCreated: boolean to the RepoUpgradeData interface so the field is included in --json output.
  • The log-mode renderRepoUpgrade function is unchanged — it deliberately omits fine-grained details and only logs the version transition.

src/cli/commands/repo_init.ts

  • Added gitignoreCreated: result.gitignoreCreated to the manually-constructed RepoUpgradeData object in the upgrade command handler. This file was not called out in the original plan but is required for the TypeScript compiler to accept the updated interface.

src/domain/repo/repo_service_test.ts

  • RepoService.upgrade creates .gitignore if missing — inits a repo, deletes the .gitignore, runs upgrade(), and asserts the file is recreated with the expected content and that gitignoreCreated === true.
  • RepoService.upgrade does not overwrite existing .gitignore — inits a repo (which creates .gitignore), runs upgrade(), and asserts gitignoreCreated === false.

Test plan

  • deno check — no type errors
  • deno lint — no lint warnings
  • deno fmt — no formatting changes
  • deno run test src/domain/repo/repo_service_test.ts — all 37 repo-service tests pass (including 2 new ones)
  • deno run test — full suite of 1795 tests passes

🤖 Generated with Claude Code

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved

This PR correctly adds .gitignore creation during swamp repo upgrade when the file is missing, mirroring the existing behavior in repo init.

Review Findings

No blocking issues found.

Code Quality

  • ✅ TypeScript strict mode - no any types introduced
  • ✅ Named exports used throughout
  • ✅ AGPLv3 headers present on all files
  • ✅ Code follows existing patterns consistently

Domain-Driven Design

  • RepoUpgradeResult properly extended as a domain result object
  • RepoService correctly reuses existing createGitignoreIfNotExists() method
  • ✅ Presentation layer (RepoUpgradeData) properly mirrors domain changes
  • ✅ Clear separation of concerns maintained

Test Coverage

  • ✅ Two comprehensive tests added covering:
    • Creating .gitignore if missing
    • Not overwriting existing .gitignore
  • ✅ Tests follow existing patterns with withTempDir and @std/assert

Security

  • ✅ No vulnerabilities - reuses existing secure file creation logic

The changes are minimal, focused, and well-tested. Good work!

🤖 Reviewed by Claude

@stack72 stack72 merged commit 6c5654c into main Feb 20, 2026
4 checks passed
@stack72 stack72 deleted the feat/repo-upgrade-gitignore branch February 20, 2026 21:09
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