Add non-Git projects across filesystem mounts (#2187)

* fix(projects): allow non-git folders across mounts

Treat failed Git worktree discovery as non-Git so ordinary directories remain addable. Preserve the underlying diagnostic as a structured warning instead of failing project creation.

* fix(projects): preserve discovery warnings

Propagate checkout context through the remaining worktree discovery calls so fail-open classification retains its structured warning.
This commit is contained in:
Mohamed Boudra
2026-07-18 11:49:11 +02:00
committed by GitHub
parent a1de743ef6
commit b4a5b6a3ff
2 changed files with 43 additions and 14 deletions
@@ -8,10 +8,12 @@ import {
readFileSync,
realpathSync,
mkdirSync,
statSync,
} from "fs";
import { join } from "path";
import { win32 } from "node:path";
import { tmpdir } from "os";
import pino from "pino";
import {
__resetCheckoutShortstatCacheForTests,
__resetPullRequestStatusCacheForTests,
@@ -314,6 +316,38 @@ describe("checkout git utilities", () => {
await expect(getCheckoutStatus(nonGitDir)).resolves.toEqual({ isGit: false });
});
it.runIf(
process.platform !== "win32" &&
existsSync("/dev/shm") &&
statSync("/dev").dev !== statSync("/dev/shm").dev,
)("warns and reports a non-git directory at a filesystem boundary as non-git", async () => {
const nonGitDir = realpathSync.native(mkdtempSync("/dev/shm/checkout-git-boundary-test-"));
const records: unknown[] = [];
const logger = pino(
{ level: "warn" },
{
write(line: string) {
records.push(JSON.parse(line));
},
},
);
try {
await expect(getCheckoutStatus(nonGitDir, { logger })).resolves.toEqual({ isGit: false });
expect(records).toEqual([
expect.objectContaining({
level: 40,
cwd: nonGitDir,
msg: "Git worktree discovery failed; treating directory as non-Git",
err: expect.objectContaining({
message: expect.stringContaining("Stopping at filesystem boundary"),
}),
}),
]);
} finally {
rmSync(nonGitDir, { recursive: true, force: true });
}
});
it("returns null for getCurrentBranch in a repo with no commits", async () => {
const emptyRepo = join(tempDir, "empty-repo");
mkdirSync(emptyRepo, { recursive: true });