fix(git): silence getWorktrees warning when directory is not a repo
`getWorktrees` logs a warn-level line every time the managed OpenCode process or any other caller passes a directory that is not inside a git repository. The OpenChamber desktop main.log fills with hundreds of these "Failed to list worktrees, returning empty list: fatal: not a git repository ..." entries over a normal session. The empty-list fallback is already correct (worktrees are an optional feature), but the warning is noise that hides real git failures. Use the existing `isNotGitRepositoryError` helper to suppress the warn specifically for the "not a git repository" case and keep the warning for genuine failures (lock contention, permission errors, corrupt repos, etc.).
This commit is contained in:
@@ -3738,7 +3738,15 @@ export async function getWorktrees(directory) {
|
||||
path: entry.worktree,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.warn('Failed to list worktrees, returning empty list:', error?.message || error);
|
||||
// Worktrees are an optional feature. When the caller passes a directory
|
||||
// that is not inside any git repository (for example, the managed
|
||||
// OpenCode's working directory or an unconfigured project path), git
|
||||
// exits with "fatal: not a git repository ...". Treat that as an
|
||||
// authoritative empty result so the route handler can still respond
|
||||
// 200 [] and the desktop main.log stays free of noise.
|
||||
if (!isNotGitRepositoryError(error)) {
|
||||
console.warn('Failed to list worktrees, returning empty list:', error?.message || error);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user