Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions packages/source-control-gitlab/src/server/GitLabCli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,44 @@ layer("GitLabCli.layer", (it) => {
}),
);

it.effect("reads an MR list whose descriptions pass the default output cap", () =>
Effect.gen(function* () {
const stdout = JSON.stringify([
{
iid: 44,
title: "Update dependencies",
web_url: "https://gitlab.com/pingdotgg/t3code/-/merge_requests/44",
target_branch: "main",
source_branch: "renovate/all",
state: "opened",
description: "x".repeat(1_100_000),
},
]);
assert.isAbove(Buffer.byteLength(stdout), 1_000_000);
mockedRun.mockImplementationOnce(({ maxOutputBytes = 1_000_000 }) =>
Effect.succeed(
stdout.length > maxOutputBytes
? { ...processOutput(stdout.slice(0, maxOutputBytes)), stdoutTruncated: true }
: processOutput(stdout),
),
);

const result = yield* Effect.gen(function* () {
const glab = yield* GitLabCli.GitLabCli;
return yield* glab.listMergeRequests({
cwd: "/repo",
headSelector: "renovate/all",
state: "open",
});
});

assert.deepStrictEqual(
result.map(({ number, state }) => ({ number, state })),
[{ number: 44, state: "open" }],
);
}),
);

it.effect("surfaces a friendly error when the merge request is not found", () =>
Effect.gen(function* () {
const cause = new VcsProcessExitError({
Expand Down
3 changes: 3 additions & 0 deletions packages/source-control-gitlab/src/server/GitLabCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
import type * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";

const DEFAULT_TIMEOUT_MS = 30_000;
// Each list row carries its whole description, so long ones pass the default 1 MB output cap.
const MERGE_REQUEST_LIST_MAX_OUTPUT_BYTES = 16 * 1024 * 1024;

const gitLabCliExecutionErrorContext = {
operation: Schema.Literal("execute"),
Expand Down Expand Up @@ -491,6 +493,7 @@ export const make = Effect.gen(function* () {
"--output",
"json",
],
maxOutputBytes: MERGE_REQUEST_LIST_MAX_OUTPUT_BYTES,
}).pipe(
Effect.map((result) => result.stdout.trim()),
Effect.flatMap((raw) =>
Expand Down
Loading