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:
@@ -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", {
|
||||
|
||||
Reference in New Issue
Block a user