feat(config): auto-detect jj checkouts#264
Conversation
Greptile SummaryThis PR wires up automatic Jujutsu-checkout detection into
Confidence Score: 4/5Safe to merge — the auto-detection logic is straightforward and the merge order keeps all existing config overrides intact. The change is small and well-contained. No files require special attention; Important Files Changed
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/core/config.test.ts:191-238
**Missing "no repo root" auto-detection case**
The new auto-detection tests cover jj-only, colocated, git-only, and config-override scenarios, but not the case where `cwd` is outside any checkout entirely (`findRepoRoot` returns `undefined`). In that case `detectRepoVcsMode(undefined)` falls through to `"git"`, which is the desired behaviour. The existing pre-PR test exercises this path only incidentally (its `cwd` is a plain temp dir), so a targeted assertion here — e.g., `createTempDir` with no `.git`/`.jj` and asserting `vcs === "git"` — would make the intended no-repo default explicit and guard against future regressions in that branch.
Reviews (1): Last reviewed commit: "feat(config): auto-detect jj checkouts" | Re-trigger Greptile |
| test("auto-detects jj checkouts before falling back to git mode", () => { | ||
| const home = createTempDir("hunk-config-home-"); | ||
| const jjRepo = createTempDir("hunk-config-jj-repo-"); | ||
| const colocatedRepo = createTempDir("hunk-config-colocated-repo-"); | ||
| const gitRepo = createTempDir("hunk-config-git-repo-"); | ||
|
|
||
| createJjRepo(jjRepo); | ||
| createRepo(colocatedRepo); | ||
| createJjRepo(colocatedRepo); | ||
| createRepo(gitRepo); | ||
|
|
||
| const input = { | ||
| kind: "vcs", | ||
| staged: false, | ||
| options: {}, | ||
| } satisfies CliInput; | ||
|
|
||
| expect( | ||
| resolveConfiguredCliInput(input, { cwd: jjRepo, env: { HOME: home } }).input.options.vcs, | ||
| ).toBe("jj"); | ||
| expect( | ||
| resolveConfiguredCliInput(input, { cwd: colocatedRepo, env: { HOME: home } }).input.options | ||
| .vcs, | ||
| ).toBe("jj"); | ||
| expect( | ||
| resolveConfiguredCliInput(input, { cwd: gitRepo, env: { HOME: home } }).input.options.vcs, | ||
| ).toBe("git"); | ||
| }); | ||
|
|
||
| test("explicit config overrides auto-detected jj mode", () => { | ||
| const home = createTempDir("hunk-config-home-"); | ||
| const repo = createTempDir("hunk-config-jj-repo-"); | ||
| createJjRepo(repo); | ||
|
|
||
| mkdirSync(join(repo, ".hunk"), { recursive: true }); | ||
| writeFileSync(join(repo, ".hunk", "config.toml"), 'vcs = "git"\n'); | ||
|
|
||
| const resolved = resolveConfiguredCliInput( | ||
| { | ||
| kind: "vcs", | ||
| staged: false, | ||
| options: {}, | ||
| }, | ||
| { cwd: repo, env: { HOME: home } }, | ||
| ); | ||
|
|
||
| expect(resolved.input.options.vcs).toBe("git"); | ||
| }); |
There was a problem hiding this comment.
Missing "no repo root" auto-detection case
The new auto-detection tests cover jj-only, colocated, git-only, and config-override scenarios, but not the case where cwd is outside any checkout entirely (findRepoRoot returns undefined). In that case detectRepoVcsMode(undefined) falls through to "git", which is the desired behaviour. The existing pre-PR test exercises this path only incidentally (its cwd is a plain temp dir), so a targeted assertion here — e.g., createTempDir with no .git/.jj and asserting vcs === "git" — would make the intended no-repo default explicit and guard against future regressions in that branch.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/core/config.test.ts
Line: 191-238
Comment:
**Missing "no repo root" auto-detection case**
The new auto-detection tests cover jj-only, colocated, git-only, and config-override scenarios, but not the case where `cwd` is outside any checkout entirely (`findRepoRoot` returns `undefined`). In that case `detectRepoVcsMode(undefined)` falls through to `"git"`, which is the desired behaviour. The existing pre-PR test exercises this path only incidentally (its `cwd` is a plain temp dir), so a targeted assertion here — e.g., `createTempDir` with no `.git`/`.jj` and asserting `vcs === "git"` — would make the intended no-repo default explicit and guard against future regressions in that branch.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Added an explicit no-repo assertion to the auto-detection coverage. The test now checks jj-only, colocated jj/git, git-only, and plain-directory fallback cases.
Responded by Pi using OpenAI GPT-5.
This comment was generated by Pi using OpenAI GPT-5
802b499 to
1b63d03
Compare
1b63d03 to
f75addd
Compare
Summary
.jjcheckouts as Jujutsu-backed reviews by defaultTesting
bun test src/core/config.test.tsbun run typecheckbun run format:checkThis PR description was generated by Pi using OpenAI GPT-5