Skip to content
Open
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
20 changes: 11 additions & 9 deletions apps/server/src/pullRequest/GiteaPullRequestApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ export const make = Effect.gen(function* () {
viewer: input.viewer,
page,
limit: PAGE_SIZE,
includeTracking: input.includeTracking,
includeTracking: input.includeTracking === true,
});
let rowsSeen = 0;
let rowsSkipped = 0;
Expand Down Expand Up @@ -911,7 +911,7 @@ export const make = Effect.gen(function* () {
host: input.host,
repository: input.repository,
number,
includeTracking: input.includeTracking,
includeTracking: input.includeTracking === true,
});
},
{ concurrency: SEARCH_HYDRATION_CONCURRENCY },
Expand Down Expand Up @@ -1525,7 +1525,9 @@ export const make = Effect.gen(function* () {

const getAutoMergeEnabled = Effect.fn("GiteaPullRequestApi.getAutoMergeEnabled")(
function* (input: { host: string; repository: string; number: number }) {
const features = yield* getFeatures.pipe(Effect.orElseSucceed(() => []));
const features = yield* getFeatures.pipe(
Effect.orElseSucceed((): ReadonlyArray<string> => []),
);
if (features.includes("pull-auto-merge-state")) {
return (yield* getPullRequest(input)).autoMergeEnabled;
}
Expand Down Expand Up @@ -1573,7 +1575,7 @@ export const make = Effect.gen(function* () {
number: number;
action: Extract<PullRequestAction, "draft" | "ready">;
}) {
const features = yield* getFeatures.pipe(Effect.orElseSucceed(() => []));
const features = yield* getFeatures.pipe(Effect.orElseSucceed((): ReadonlyArray<string> => []));
if (features.includes("pull-draft")) {
return yield* write({
operation: "runAction",
Expand Down Expand Up @@ -1643,7 +1645,7 @@ export const make = Effect.gen(function* () {
subjectIds: ReadonlyArray<string>;
}) {
const supportsReviewReactions = (yield* getFeatures.pipe(
Effect.orElseSucceed(() => []),
Effect.orElseSucceed((): ReadonlyArray<string> => []),
)).includes("pull-review-reactions");
const targets: Array<{
readonly subjectId: string | undefined;
Expand Down Expand Up @@ -2008,7 +2010,7 @@ export const make = Effect.gen(function* () {
...input,
path: `${basePath(input.repository)}/teams`,
}).pipe(
Effect.catchTag("GiteaPullRequestApiError", (error: GiteaPullRequestApiError) =>
Effect.catch((error) =>
isGiteaApiError(error.cause) && error.cause.status === 405
? Effect.succeed([])
: Effect.fail(error),
Expand Down Expand Up @@ -2165,9 +2167,9 @@ export const make = Effect.gen(function* () {
return Effect.gen(function* () {
if (
target.kind === "review" &&
!(yield* getFeatures.pipe(Effect.orElseSucceed(() => []))).includes(
"pull-review-reactions",
)
!(yield* getFeatures.pipe(
Effect.orElseSucceed((): ReadonlyArray<string> => []),
)).includes("pull-review-reactions")
) {
return yield* new GiteaPullRequestApiError({
operation: "setReaction",
Expand Down
8 changes: 4 additions & 4 deletions apps/server/src/pullRequest/GiteaPullRequestProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ export const make = Effect.gen(function* () {
}) =>
giteaViewerPermissions({
canWrite: input.access.canWrite,
workflowApprovalSupported: input.workflowApprovalSupported,
revertSupported: input.revertSupported,
workflowApprovalSupported: input.workflowApprovalSupported === true,
revertSupported: input.revertSupported === true,
ownsPullRequest:
input.author !== undefined && input.author.toLowerCase() === input.viewer.toLowerCase(),
updateMethods: input.access.updateMethods,
Expand Down Expand Up @@ -195,7 +195,7 @@ export const make = Effect.gen(function* () {
api
.getWorkflowApprovals(input)
.pipe(Effect.orElseSucceed(() => ({ supported: false, runs: [] }))),
api.getFeatures().pipe(Effect.orElseSucceed(() => [])),
api.getFeatures().pipe(Effect.orElseSucceed((): ReadonlyArray<string> => [])),
],
{ concurrency: 4 },
).pipe(
Expand Down Expand Up @@ -326,7 +326,7 @@ export const make = Effect.gen(function* () {
api.getPullRequest(input),
api.getRepositoryAccess(input),
api.getViewer(),
api.getFeatures().pipe(Effect.orElseSucceed(() => [])),
api.getFeatures().pipe(Effect.orElseSucceed((): ReadonlyArray<string> => [])),
],
{
concurrency: 3,
Expand Down
9 changes: 6 additions & 3 deletions apps/server/src/pullRequest/GiteaWorkflows.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { assert, expect, it, vi } from "@effect/vitest";
import * as Effect from "effect/Effect";
import * as Option from "effect/Option";
import * as Schema from "effect/Schema";

import * as GiteaApi from "../sourceControl/GiteaApi.ts";
import { isCurrentPullWorkflow, list } from "./GiteaWorkflows.ts";

const encodeJson = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown));

const run = {
id: 7,
needs_approval: true,
Expand Down Expand Up @@ -33,7 +36,7 @@ it.effect("reads capped pages completely and selects only this PR's current bloc
const request = vi.fn<GiteaApi.GiteaApi["Service"]["request"]>();
request.mockReturnValueOnce(
Effect.succeed({
body: JSON.stringify({
body: encodeJson({
total_count: 2,
workflow_runs: [{ ...run, pull_request_head_sha: "old" }],
}),
Expand All @@ -43,7 +46,7 @@ it.effect("reads capped pages completely and selects only this PR's current bloc
);
request.mockReturnValueOnce(
Effect.succeed({
body: JSON.stringify({ total_count: 2, workflow_runs: [run] }),
body: encodeJson({ total_count: 2, workflow_runs: [run] }),
truncated: false,
headers: {},
}),
Expand All @@ -62,7 +65,7 @@ it.effect("fails incomplete pagination instead of reporting no approvals", () =>
Effect.gen(function* () {
const request = vi.fn<GiteaApi.GiteaApi["Service"]["request"]>(() =>
Effect.succeed({
body: JSON.stringify({ total_count: 1, workflow_runs: [] }),
body: encodeJson({ total_count: 1, workflow_runs: [] }),
truncated: false,
headers: {},
}),
Expand Down