feat: add git-backed session review modes (#17961)

This commit is contained in:
Shoubhit Dash
2026-03-19 19:29:29 +05:30
committed by GitHub
parent 84f60d97a0
commit e6f5214779
26 changed files with 1072 additions and 183 deletions

View File

@@ -10,14 +10,16 @@ import { ProjectID } from "../../src/project/schema"
Log.init({ print: false })
const gitModule = await import("../../src/util/git")
const originalGit = gitModule.git
const gitModule = await import("../../src/git")
const originalGit = gitModule.Git.run
type Mode = "none" | "rev-list-fail" | "top-fail" | "common-dir-fail"
let mode: Mode = "none"
mock.module("../../src/util/git", () => ({
git: (args: string[], opts: { cwd: string; env?: Record<string, string> }) => {
mock.module("../../src/git", () => ({
Git: {
...gitModule.Git,
run: (args: string[], opts: { cwd: string; env?: Record<string, string> }) => {
const cmd = ["git", ...args].join(" ")
if (
mode === "rev-list-fail" &&
@@ -27,7 +29,7 @@ mock.module("../../src/util/git", () => ({
) {
return Promise.resolve({
exitCode: 128,
text: () => Promise.resolve(""),
text: () => "",
stdout: Buffer.from(""),
stderr: Buffer.from("fatal"),
})
@@ -35,7 +37,7 @@ mock.module("../../src/util/git", () => ({
if (mode === "top-fail" && cmd.includes("git rev-parse") && cmd.includes("--show-toplevel")) {
return Promise.resolve({
exitCode: 128,
text: () => Promise.resolve(""),
text: () => "",
stdout: Buffer.from(""),
stderr: Buffer.from("fatal"),
})
@@ -43,12 +45,13 @@ mock.module("../../src/util/git", () => ({
if (mode === "common-dir-fail" && cmd.includes("git rev-parse") && cmd.includes("--git-common-dir")) {
return Promise.resolve({
exitCode: 128,
text: () => Promise.resolve(""),
text: () => "",
stdout: Buffer.from(""),
stderr: Buffer.from("fatal"),
})
}
return originalGit(args, opts)
},
},
}))