Skip to content

Commit 1535d69

Browse files
committed
fix(server): harden temporary review indexes
1 parent 007435f commit 1535d69

1 file changed

Lines changed: 27 additions & 14 deletions

File tree

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,10 +2160,20 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
21602160
const sharedIndexPath = path.isAbsolute(sharedIndexValue)
21612161
? sharedIndexValue
21622162
: path.resolve(cwd, sharedIndexValue);
2163-
yield* fileSystem.copyFile(
2164-
sharedIndexPath,
2165-
path.join(tempDirectory, path.basename(sharedIndexPath)),
2166-
);
2163+
yield* fileSystem
2164+
.copyFile(sharedIndexPath, path.join(tempDirectory, path.basename(sharedIndexPath)))
2165+
.pipe(
2166+
Effect.mapError(
2167+
(cause) =>
2168+
new GitCommandError({
2169+
operation: "GitVcsDriver.readWorkingTreeReviewDiff.copySharedIndex",
2170+
command: "git diff",
2171+
cwd,
2172+
detail: "Failed to copy the shared Git index for the review diff.",
2173+
cause,
2174+
}),
2175+
),
2176+
);
21672177
yield* executeGit(
21682178
"GitVcsDriver.readWorkingTreeReviewDiff.expandSplitIndex",
21692179
cwd,
@@ -2181,15 +2191,15 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
21812191
}
21822192

21832193
const stagedDeletionResult = hasHead
2184-
? yield* executeGit("GitVcsDriver.readWorkingTreeReviewDiff.stagedDeletions", cwd, [
2185-
"diff",
2186-
"--cached",
2187-
"--name-only",
2188-
"--diff-filter=D",
2189-
"-z",
2190-
"HEAD",
2191-
"--",
2192-
])
2194+
? yield* executeGit(
2195+
"GitVcsDriver.readWorkingTreeReviewDiff.stagedDeletions",
2196+
cwd,
2197+
["diff", "--cached", "--name-only", "--diff-filter=D", "-z", "HEAD", "--"],
2198+
{
2199+
maxOutputBytes: WORKSPACE_FILES_MAX_OUTPUT_BYTES,
2200+
appendTruncationMarker: true,
2201+
},
2202+
)
21932203
: null;
21942204
const stagedDeletions = new Set(
21952205
stagedDeletionResult ? splitNullSeparatedGitStdoutPaths(stagedDeletionResult) : [],
@@ -2242,7 +2252,10 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
22422252
);
22432253
return {
22442254
...result,
2245-
stdoutTruncated: result.stdoutTruncated || untrackedResult.stdoutTruncated,
2255+
stdoutTruncated:
2256+
result.stdoutTruncated ||
2257+
stagedDeletionResult?.stdoutTruncated === true ||
2258+
untrackedResult.stdoutTruncated,
22462259
};
22472260
}).pipe(
22482261
Effect.ensuring(

0 commit comments

Comments
 (0)