Skip to content

Commit 51cf41d

Browse files
committed
fix(vcs): detect non-git repos in status commands via stderr check
When git status or rev-parse fails with a non-zero exit code in a directory that is not a git repository, the stderr contains 'not a git repository'. Previously the code would throw a GitCommandError with a generic detail message, which prevented GitManager.isNotGitRepositoryError from matching and returning isRepo: false. Add stderr substring checks in readStatusDetailsLocal and readStatusDetailsRemote to return the non-repository sentinel values, consistent with listRefs.
1 parent c4d0cd4 commit 51cf41d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

apps/server/src/vcs/GitVcsDriverCore.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
11961196
return NON_REPOSITORY_REMOTE_STATUS_DETAILS;
11971197
}
11981198
if (branchResult.exitCode !== 0) {
1199+
if (branchResult.stderr.toLowerCase().includes("not a git repository")) {
1200+
return NON_REPOSITORY_REMOTE_STATUS_DETAILS;
1201+
}
11991202
return yield* new GitCommandError({
12001203
...gitCommandContext({
12011204
operation: "GitVcsDriver.statusDetailsRemote.branch",
@@ -1316,6 +1319,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
13161319
}
13171320

13181321
if (statusResult.exitCode !== 0) {
1322+
if (statusResult.stderr.toLowerCase().includes("not a git repository")) {
1323+
return NON_REPOSITORY_STATUS_DETAILS;
1324+
}
13191325
return yield* new GitCommandError({
13201326
...gitCommandContext({
13211327
operation: "GitVcsDriver.statusDetails.status",

0 commit comments

Comments
 (0)