test(git): cover worktrees, untracked files, and the OWNERSHIP-deletion gap#199
Conversation
…on gap Adds coverage the codeowners early-exit work (bestdan#193) was missing: - getFilesToPushWithStatus: detection from inside a linked git worktree, both with and without a remote (mirrors the existing non-worktree cases). - getAllChangedFilesWithStatus: untracked working-tree files are ignored in push mode. - isCodeownersRelevant + detection: characterize that a committed OWNERSHIP deletion is stripped by --diff-filter=ACMR and never reaches the gate, with an it.todo marking the gap to close. src-only; compiled *.test.js are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces several unit tests to verify Git utility behaviors, including handling untracked files, identifying relevant codeowners changes, and retrieving files to push within linked worktrees. The review feedback highlights a potential issue in the test cleanup blocks where a failure in one rmSync call could prevent subsequent temporary directories from being deleted. It is recommended to wrap these cleanup operations in nested try...finally blocks to guarantee that all temporary directories are reliably removed.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| } finally { | ||
| rmSync(tempDir, { recursive: true, force: true }); | ||
| rmSync(worktreeParent, { recursive: true, force: true }); | ||
| } |
There was a problem hiding this comment.
If rmSync(tempDir) fails (e.g., due to file locking issues on Windows), the finally block will throw and prevent rmSync(worktreeParent) from executing, leaving orphaned temporary directories. Wrapping the cleanups in nested try...finally blocks ensures both directories are always cleaned up.
| } finally { | |
| rmSync(tempDir, { recursive: true, force: true }); | |
| rmSync(worktreeParent, { recursive: true, force: true }); | |
| } | |
| } finally { | |
| try { | |
| rmSync(tempDir, { recursive: true, force: true }); | |
| } finally { | |
| rmSync(worktreeParent, { recursive: true, force: true }); | |
| } | |
| } |
| } finally { | ||
| rmSync(tempDir, { recursive: true, force: true }); | ||
| rmSync(remoteDir, { recursive: true, force: true }); | ||
| rmSync(worktreeParent, { recursive: true, force: true }); | ||
| } |
There was a problem hiding this comment.
Similarly, if any of the rmSync calls fail, the subsequent cleanups will be skipped. Wrapping them in nested try...finally blocks ensures that all temporary directories (tempDir, remoteDir, and worktreeParent) are reliably cleaned up.
} finally {
try {
rmSync(tempDir, { recursive: true, force: true });
} finally {
try {
rmSync(remoteDir, { recursive: true, force: true });
} finally {
rmSync(worktreeParent, { recursive: true, force: true });
}
}
}
Follow-up to #193 (now merged). Adds the test coverage that work was missing — exercised manually against the branch before merge, now locked in as tests against
main.What this adds
src-only — the compiled*.test.jsare gitignored, so there are nodistchanges.Worktrees —
get-files-to-push-with-status.test.tsgetFilesToPushWithStatuscalled from inside a linkedgit worktree, no remote → fullmain...HEADrange with statuses.Confirms detection and the
origin/<branch>remote resolution work when.gitis a file rather than a directory (the case the suite didn't cover).Untracked files —
get-all-changed-files-with-status.test.tsOWNERSHIP-deletion gap —get-all-changed-files-with-status.test.ts+is-codeowners-relevant.test.tsOWNERSHIPdeletion is stripped by--diff-filter=ACMR, so it never reachesisCodeownersRelevantand codeowners is skipped for that push — leaving a directory potentially orphaned.isCodeownersRelevantwould flag a deletedOWNERSHIPby name (added test), so the gap is in detection (Dis filtered out upstream), not the gate.it.todomarks the behavior to close (surface ownership-file deletions so codeowners can re-validate).Verification
main.prettier --check,eslint,tsc --noEmit: clean.