feat: create .gitignore during repo upgrade if missing#409
Merged
Conversation
There was a problem hiding this comment.
✅ 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
anytypes introduced - ✅ Named exports used throughout
- ✅ AGPLv3 headers present on all files
- ✅ Code follows existing patterns consistently
Domain-Driven Design
- ✅
RepoUpgradeResultproperly extended as a domain result object - ✅
RepoServicecorrectly reuses existingcreateGitignoreIfNotExists()method - ✅ Presentation layer (
RepoUpgradeData) properly mirrors domain changes - ✅ Clear separation of concerns maintained
Test Coverage
- ✅ Two comprehensive tests added covering:
- Creating
.gitignoreif missing - Not overwriting existing
.gitignore
- Creating
- ✅ Tests follow existing patterns with
withTempDirand@std/assert
Security
- ✅ No vulnerabilities - reuses existing secure file creation logic
The changes are minimal, focused, and well-tested. Good work!
🤖 Reviewed by Claude
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.
Summary
swamp repo upgradedid not check for or create a.gitignorefile, unlikeswamp repo initwhich callscreateGitignoreIfNotExists. This meant repos initialised before gitignore support was added, or repos where the file was accidentally deleted, would not get a.gitignoreon 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.tsgitignoreCreated: booleanto theRepoUpgradeResultinterface.createGitignoreIfNotExists(repoPath, tool)insideupgrade()after the Claude-settings block, before the return statement.gitignoreCreatedin the return value.src/presentation/output/repo_output.tsgitignoreCreated: booleanto theRepoUpgradeDatainterface so the field is included in--jsonoutput.renderRepoUpgradefunction is unchanged — it deliberately omits fine-grained details and only logs the version transition.src/cli/commands/repo_init.tsgitignoreCreated: result.gitignoreCreatedto the manually-constructedRepoUpgradeDataobject 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.tsRepoService.upgrade creates .gitignore if missing— inits a repo, deletes the.gitignore, runsupgrade(), and asserts the file is recreated with the expected content and thatgitignoreCreated === true.RepoService.upgrade does not overwrite existing .gitignore— inits a repo (which creates.gitignore), runsupgrade(), and assertsgitignoreCreated === false.Test plan
deno check— no type errorsdeno lint— no lint warningsdeno fmt— no formatting changesdeno 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