Skip to content

Commit cae8880

Browse files
committed
fix(gitlab): simplify stats recovery and preserve tracing
1 parent 4aaae55 commit cae8880

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

‎packages/source-control-gitlab/src/server/GitLabPullRequestCli.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,4 +1249,27 @@ layer("GitLabPullRequestCli.layer", (it) => {
12491249
]);
12501250
}),
12511251
);
1252+
it.effect.each([
1253+
GitLabCli.GitLabCliUnavailableError,
1254+
GitLabCli.GitLabCliAuthenticationError,
1255+
GitLabCli.GitLabCliRateLimitError,
1256+
])("propagates unusable CLI and account failures from stats (%s)", (ErrorType) =>
1257+
Effect.gen(function* () {
1258+
const error = new ErrorType({
1259+
operation: "execute",
1260+
command: "glab",
1261+
cwd: "/w",
1262+
cause: null,
1263+
});
1264+
mockedExecute.mockReturnValueOnce(Effect.fail(error));
1265+
const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli;
1266+
const result = yield* Effect.result(
1267+
cli.listMergeRequestStats({
1268+
cwd: "/w",
1269+
changeRequests: [{ repository: "acme/web", number: 7 }],
1270+
}),
1271+
);
1272+
expect(result).toMatchObject({ _tag: "Failure", failure: error });
1273+
}),
1274+
);
12521275
});

‎packages/source-control-gitlab/src/server/GitLabPullRequestCli.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,14 +1251,15 @@ export const make = Effect.gen(function* () {
12511251

12521252
listMergeRequestStats,
12531253

1254-
getMergeRequestFileStats: (input) =>
1254+
getMergeRequestFileStats: Effect.fn("GitLabPullRequestCli.getMergeRequestFileStats")((input) =>
12551255
graphqlRead({
12561256
cwd: input.cwd,
12571257
operation: "getMergeRequestFileStats",
12581258
query: MERGE_REQUEST_FILE_STATS_GRAPHQL_QUERY,
12591259
variables: { fullPath: input.repository, iid: String(input.number) },
12601260
decode: decodeMergeRequestFileStatsJson,
12611261
}),
1262+
),
12621263

12631264
listNotes: Effect.fn("GitLabPullRequestCli.listNotes")(function (input) {
12641265
return notesPage({ ...input, page: 1, collected: [] });

‎packages/source-control-gitlab/src/server/GitLabPullRequestProvider.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,7 @@ export const make = Effect.gen(function* () {
111111
}),
112112
);
113113

114-
/**
115-
* The REST detail carries no line counts, so they are read alongside it. A failed count read
116-
* leaves them at zero, which the page already shows as no counts, rather than failing the
117-
* read; an unusable CLI or account still fails it, as every optional read here does.
118-
*/
114+
// REST omits line counts; the CLI recovers optional stats failures per batch.
119115
const mergeRequestWithStats = (input: {
120116
readonly cwd: string;
121117
readonly repository: string;
@@ -124,7 +120,7 @@ export const make = Effect.gen(function* () {
124120
Effect.all(
125121
[
126122
cli.getMergeRequestDetail(input),
127-
recoverRead(cli.listMergeRequestStats({ cwd: input.cwd, changeRequests: [input] }), []),
123+
cli.listMergeRequestStats({ cwd: input.cwd, changeRequests: [input] }),
128124
],
129125
{ concurrency: 2 },
130126
).pipe(

0 commit comments

Comments
 (0)