feat(FN-2621): guard execution for non-git project directories

- Add isGitRepository utility in worktree-pool using git rev-parse checks
- Fail fast in TaskExecutor with actionable non-git errors before worktree creation starts
- Classify not-a-git-repository worktree add failures as non-retryable in recovery flows
- Warn from in-process runtime startup when the working directory is not a Git repository
- Expand executor and worktree-pool tests to cover non-git, missing-dir, and conflict-classification paths
This commit is contained in:
Fusion
2026-04-26 22:20:17 -07:00
committed by gsxdsm
parent 4f5b8f2260
commit 163a4c734c
5 changed files with 191 additions and 3 deletions

View File

@@ -7,6 +7,20 @@ import { worktreePoolLog } from "./logger.js";
const execAsync = promisify(exec);
export async function isGitRepository(dir: string): Promise<boolean> {
try {
await execAsync("git rev-parse --git-dir", {
cwd: dir,
encoding: "utf-8",
});
return true;
} catch (err: unknown) {
const errorMessage = err instanceof Error ? err.message : String(err);
worktreePoolLog.log(`isGitRepository check failed for ${dir}: ${errorMessage}`);
return false;
}
}
export async function getRegisteredWorktreePaths(rootDir: string): Promise<Set<string>> {
try {
const { stdout } = await execAsync("git worktree list --porcelain", {