History

feat(source-control): add Bitbucket & Azure Devops providers (#2473)

Julius Marminge committed 6 months agov0.0.22-nightly.20260504.196

Commit 91a03e01 parent d501ebe59 files · +5834 −2327Browse files

Showing the changes to apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts (1 of 59 files). Show all

Unified · Split

apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts+48−9
@@ -1,11 +1,16 @@
11 import { assert, it } from "@effect/vitest";
2+import * as NodeServices from "@effect/platform-node/NodeServices";
23 import { DateTime, Effect, Layer, Option } from "effect";
34
4−import { GitHubCli } from "./GitHubCli.ts";
5−import { GitLabCli } from "./GitLabCli.ts";
5+import { ServerConfig } from "../config.ts";
6+import type * as VcsDriver from "../vcs/VcsDriver.ts";
7+import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
8+import * as VcsProcess from "../vcs/VcsProcess.ts";
9+import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
10+import * as BitbucketApi from "./BitbucketApi.ts";
11+import * as GitHubCli from "./GitHubCli.ts";
12+import * as GitLabCli from "./GitLabCli.ts";
613 import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";
7−import { VcsDriverRegistry } from "../vcs/VcsDriverRegistry.ts";
8−import type { VcsDriverShape } from "../vcs/VcsDriver.ts";
914
1015 const TEST_EPOCH = DateTime.makeUnsafe("1970-01-01T00:00:00.000Z");
1116
@@ -29,10 +34,10 @@ function makeRegistry(input: { · 17 unmodified lines
2934 expiresAt: Option.none(),
3035 },
3136 }),
32− } satisfies Partial<VcsDriverShape>;
37+ } satisfies Partial<VcsDriver.VcsDriverShape>;
3338
34− const registryLayer = Layer.mock(VcsDriverRegistry)({
35− get: () => Effect.succeed(driver as unknown as VcsDriverShape),
39+ const registryLayer = Layer.mock(VcsDriverRegistry.VcsDriverRegistry)({
40+ get: () => Effect.succeed(driver as unknown as VcsDriver.VcsDriverShape),
3641 resolve: () =>
3742 Effect.succeed({
3843 kind: "git",
@@ -46,13 +51,23 @@ function makeRegistry(input: { · 7 unmodified lines
4651 expiresAt: Option.none(),
4752 },
4853 },
49− driver: driver as unknown as VcsDriverShape,
54+ driver: driver as unknown as VcsDriver.VcsDriverShape,
5055 }),
5156 });
5257
5358 return SourceControlProviderRegistry.make().pipe(
5459 Effect.provide(
55− Layer.mergeAll(registryLayer, Layer.mock(GitHubCli)({}), Layer.mock(GitLabCli)({})),
60+ Layer.mergeAll(
61+ registryLayer,
62+ Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({}),
63+ Layer.mock(BitbucketApi.BitbucketApi)({}),
64+ Layer.mock(GitHubCli.GitHubCli)({}),
65+ Layer.mock(GitLabCli.GitLabCli)({}),
66+ Layer.mock(VcsProcess.VcsProcess)({}),
67+ ServerConfig.layerTest(process.cwd(), { prefix: "t3-source-control-registry-test-" }).pipe(
68+ Layer.provide(NodeServices.layer),
69+ ),
70+ ),
5671 ),
5772 );
5873 }
@@ -93,6 +108,30 @@ it.effect("routes GitLab remotes to the GitLab provider", () => · 34 unmodified lines
93108 }),
94109 );
95110
111+it.effect("routes Bitbucket remotes to the Bitbucket provider", () =>
112+ Effect.gen(function* () {
113+ const registry = yield* makeRegistry({
114+ remotes: [{ name: "origin", url: "git@bitbucket.org:pingdotgg/t3code.git" }],
115+ });
116+
117+ const provider = yield* registry.resolve({ cwd: "/repo" });
118+
119+ assert.strictEqual(provider.kind, "bitbucket");
120+ }),
121+);
122+
123+it.effect("routes Azure DevOps remotes to the Azure DevOps provider", () =>
124+ Effect.gen(function* () {
125+ const registry = yield* makeRegistry({
126+ remotes: [{ name: "origin", url: "https://dev.azure.com/acme/project/_git/repo" }],
127+ });
128+
129+ const provider = yield* registry.resolve({ cwd: "/repo" });
130+
131+ assert.strictEqual(provider.kind, "azure-devops");
132+ }),
133+);
134+
96135 it.effect("falls back to a non-origin remote when origin is not configured", () =>
97136 Effect.gen(function* () {
98137 const registry = yield* makeRegistry({

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t