refactor(contracts): source control provider kind is an open branded slug (#17739)
Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
dacd2cb649
commit
fd3549c8ff
74 files changed
+816
-551
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { SourceControlProviderKind } from "@t3tools/contracts";
|
||||
import * as NodePath from "@effect/platform-node/NodePath";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
@@ -37,7 +38,7 @@ function makeProvider(
|
||||
>;
|
||||
|
||||
return {
|
||||
kind: "github",
|
||||
kind: SourceControlProviderKind.make("github"),
|
||||
listChangeRequests: () => unsupported("listChangeRequests"),
|
||||
getChangeRequest: () => unsupported("getChangeRequest"),
|
||||
createChangeRequest: () => unsupported("createChangeRequest"),
|
||||
@@ -114,19 +115,22 @@ it.effect("looks up repositories through the requested provider without search",
|
||||
return Effect.gen(function* () {
|
||||
const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
|
||||
const result = yield* service.lookupRepository({
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
repository: "octocat/t3code",
|
||||
cwd: "/workspace",
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(result, { provider: "github", ...CLONE_URLS });
|
||||
assert.deepStrictEqual(result, {
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
...CLONE_URLS,
|
||||
});
|
||||
assert.deepStrictEqual(calls, [{ cwd: "/workspace", repository: "octocat/t3code" }]);
|
||||
}).pipe(Effect.provide(layer({ provider })));
|
||||
});
|
||||
|
||||
it.effect("preserves provider failures without deriving the repository message from them", () => {
|
||||
const providerCause = new SourceControlProviderError({
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
operation: "getRepositoryCloneUrls",
|
||||
cwd: "/workspace",
|
||||
repository: "octocat/t3code",
|
||||
@@ -140,7 +144,7 @@ it.effect("preserves provider failures without deriving the repository message f
|
||||
const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
|
||||
const error = yield* Effect.flip(
|
||||
service.lookupRepository({
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
repository: "octocat/t3code",
|
||||
cwd: "/workspace",
|
||||
}),
|
||||
@@ -176,7 +180,7 @@ it.effect(
|
||||
yield* Effect.gen(function* () {
|
||||
const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
|
||||
const input = {
|
||||
provider: "bitbucket" as const,
|
||||
provider: SourceControlProviderKind.make("bitbucket"),
|
||||
repository: locatorCause.repository,
|
||||
cwd: "/workspace",
|
||||
};
|
||||
@@ -204,11 +208,11 @@ it.effect(
|
||||
|
||||
it.effect("keeps a plain Bitbucket locator lookalike out of the repository message", () => {
|
||||
const provider = makeProvider({
|
||||
kind: "bitbucket",
|
||||
kind: SourceControlProviderKind.make("bitbucket"),
|
||||
getRepositoryCloneUrls: () =>
|
||||
Effect.fail(
|
||||
new SourceControlProviderError({
|
||||
provider: "bitbucket",
|
||||
provider: SourceControlProviderKind.make("bitbucket"),
|
||||
operation: "getRepositoryCloneUrls",
|
||||
cwd: "/workspace",
|
||||
detail: "credential token abc123 was rejected",
|
||||
@@ -224,7 +228,10 @@ it.effect("keeps a plain Bitbucket locator lookalike out of the repository messa
|
||||
return Effect.gen(function* () {
|
||||
const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
|
||||
const error = yield* Effect.flip(
|
||||
service.lookupRepository({ provider: "bitbucket", repository: "t3code" }),
|
||||
service.lookupRepository({
|
||||
provider: SourceControlProviderKind.make("bitbucket"),
|
||||
repository: "t3code",
|
||||
}),
|
||||
);
|
||||
|
||||
assert.strictEqual(error.detail, "The source control operation could not be completed.");
|
||||
@@ -250,7 +257,7 @@ it.effect("keeps arbitrary Bitbucket request failures out of the repository mess
|
||||
const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
|
||||
const error = yield* Effect.flip(
|
||||
service.lookupRepository({
|
||||
provider: "bitbucket",
|
||||
provider: SourceControlProviderKind.make("bitbucket"),
|
||||
repository: "pingdotgg/t3code",
|
||||
cwd: "/workspace",
|
||||
}),
|
||||
@@ -276,7 +283,7 @@ it.effect("clones a looked-up repository into the requested destination", () =>
|
||||
yield* Effect.gen(function* () {
|
||||
const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
|
||||
const result = yield* service.cloneRepository({
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
repository: "octocat/t3code",
|
||||
destinationPath,
|
||||
protocol: "https",
|
||||
@@ -285,7 +292,7 @@ it.effect("clones a looked-up repository into the requested destination", () =>
|
||||
assert.deepStrictEqual(result, {
|
||||
cwd: destinationPath,
|
||||
remoteUrl: CLONE_URLS.url,
|
||||
repository: { provider: "github", ...CLONE_URLS },
|
||||
repository: { provider: SourceControlProviderKind.make("github"), ...CLONE_URLS },
|
||||
});
|
||||
assert.deepStrictEqual(cloneCalls, [
|
||||
{
|
||||
@@ -546,7 +553,7 @@ it.effect("publishes by creating the repository, adding a remote, and pushing up
|
||||
const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
|
||||
const result = yield* service.publishRepository({
|
||||
cwd: "/workspace",
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
repository: "octocat/t3code",
|
||||
visibility: "private",
|
||||
remoteName: "origin",
|
||||
@@ -554,7 +561,7 @@ it.effect("publishes by creating the repository, adding a remote, and pushing up
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(result, {
|
||||
repository: { provider: "github", ...CLONE_URLS },
|
||||
repository: { provider: SourceControlProviderKind.make("github"), ...CLONE_URLS },
|
||||
remoteName: "origin",
|
||||
remoteUrl: CLONE_URLS.sshUrl,
|
||||
branch: "feature/remote-v1",
|
||||
@@ -601,7 +608,7 @@ it.effect("publishes to the remote name returned by ensureRemote", () => {
|
||||
const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
|
||||
const result = yield* service.publishRepository({
|
||||
cwd: "/workspace",
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
repository: "octocat/t3code",
|
||||
visibility: "private",
|
||||
remoteName: "origin",
|
||||
@@ -637,7 +644,7 @@ it.effect("publish succeeds with status remote_added when the local repo has no
|
||||
const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
|
||||
const result = yield* service.publishRepository({
|
||||
cwd: "/workspace",
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
repository: "octocat/t3code",
|
||||
visibility: "private",
|
||||
remoteName: "origin",
|
||||
@@ -645,7 +652,7 @@ it.effect("publish succeeds with status remote_added when the local repo has no
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(result, {
|
||||
repository: { provider: "github", ...CLONE_URLS },
|
||||
repository: { provider: SourceControlProviderKind.make("github"), ...CLONE_URLS },
|
||||
remoteName: "origin",
|
||||
remoteUrl: CLONE_URLS.sshUrl,
|
||||
branch: "main",
|
||||
|
||||
Reference in new issue
Block a user