Skip to content

Commit f28c005

Browse files
committed
fix(server): retain checkout routing for GitLab
1 parent 1149abd commit f28c005

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

‎apps/server/src/pullRequest/PullRequestService.test.ts‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2462,7 +2462,6 @@ it.effect("refuses Azure cross-organization reads and writes without its checkou
24622462

24632463
it.effect.each([
24642464
["github.com", "github"],
2465-
["gitlab.com", "gitlab"],
24662465
["bitbucket.org", "bitbucket"],
24672466
["codeberg.org", "forgejo"],
24682467
] as const)("reads linked PR summaries and stacks on %s without a checkout", ([host, kind]) =>
@@ -2573,6 +2572,29 @@ it.effect("refuses a public host reference without a selected project directory"
25732572
}),
25742573
);
25752574

2575+
it.effect(
2576+
"requires a checkout for GitLab because its adapter does not explicitly target the host",
2577+
() =>
2578+
Effect.gen(function* () {
2579+
const service = yield* makeService({
2580+
projects: [project({ id: "inbox", title: "Inbox", workspaceRoot: "/home/alex" })],
2581+
providers: [fakeProvider("gitlab")],
2582+
});
2583+
const error = yield* service
2584+
.summary(
2585+
{
2586+
projectId: "inbox" as ProjectId,
2587+
host: "gitlab.com",
2588+
repository: "acme/api",
2589+
number: 7,
2590+
},
2591+
{ recoverTransientFailure: false },
2592+
)
2593+
.pipe(Effect.flip);
2594+
assert.strictEqual(error._tag, "PullRequestUnavailableError");
2595+
}),
2596+
);
2597+
25762598
it.effect("refuses a hosted reference when its provider is unavailable", () =>
25772599
Effect.gen(function* () {
25782600
const service = yield* makeService({

‎apps/server/src/pullRequest/PullRequestService.ts‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -882,9 +882,9 @@ export const make = Effect.gen(function* () {
882882
* The project whose checkout and credentials serve a reference. The project's own
883883
* repository is the default; a reference that names a `host` may instead point at any
884884
* repository on that host. Prefer its own checkout; providers with explicit repository
885-
* targeting can fall back to another checkout on the host. Public hosts can also use the
886-
* selected project's directory without a checkout. Azure derives its organization from
887-
* the checkout, so it requires a matching repository.
885+
* targeting can fall back to another checkout on the host. Providers with explicit host
886+
* targeting can also use the selected project's directory for supported public hosts.
887+
* Azure derives its organization from the checkout, so it requires a matching repository.
888888
*/
889889
const requireProject = (ref: PullRequestRef): Effect.Effect<SupportedProject, PullRequestError> =>
890890
listWorkspaceProjects({ projectId: ref.projectId }).pipe(
@@ -937,12 +937,8 @@ export const make = Effect.gen(function* () {
937937
return Effect.gen(function* () {
938938
// These providers target the repository explicitly and authenticate by host;
939939
// a linked PR in a non-repository project still needs its snapshot refreshed.
940-
const provider = [
941-
"github.com",
942-
"gitlab.com",
943-
"bitbucket.org",
944-
"codeberg.org",
945-
].includes(host)
940+
// GitLab still selects its host from the checkout or CLI configuration.
941+
const provider = ["github.com", "bitbucket.org", "codeberg.org"].includes(host)
946942
? detectSourceControlProviderFromRemoteUrl(`https://${host}/${repository}.git`)
947943
: null;
948944
const api = provider === null ? null : registry.get(provider.kind);

0 commit comments

Comments
 (0)