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 Clock from "effect/Clock";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Data from "effect/Data";
|
||||
@@ -389,7 +390,7 @@ export const make = Effect.gen(function* () {
|
||||
// this reads today is `core`; a `search/` read would need its own resource here. A refusal
|
||||
// still pauses the whole host, the key PullRequestService records its own backoff under.
|
||||
const resource = input.graphql === true ? "graphql" : "core";
|
||||
const key = { provider: "github" as const, host };
|
||||
const key = { provider: SourceControlProviderKind.make("github"), host };
|
||||
const run = Effect.gen(function* () {
|
||||
const lease = yield* quota
|
||||
.admit(host, resource, { allowReserve: input.allowReserve })
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SourceControlProviderKind } from "@t3tools/contracts";
|
||||
import { removeAgentCredits } from "@t3tools/source-control-core/server/mergeMessage";
|
||||
import * as Effect from "effect/Effect";
|
||||
import type {
|
||||
@@ -202,7 +203,7 @@ export const make = Effect.gen(function* () {
|
||||
|
||||
const fail = (operation: string) => (error: GitHubPullRequestApi.GitHubPullRequestApiError) =>
|
||||
new PullRequestProviderError({
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
operation,
|
||||
...gitHubProviderFailure(error),
|
||||
detail: error.message,
|
||||
@@ -261,7 +262,7 @@ export const make = Effect.gen(function* () {
|
||||
);
|
||||
|
||||
const provider: PullRequestProviderApi = {
|
||||
kind: "github",
|
||||
kind: SourceControlProviderKind.make("github"),
|
||||
capabilities: CAPABILITIES,
|
||||
mergeMessageRewrite: removeAgentCredits,
|
||||
getRoutingIdentity: (input) =>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SourceControlProviderKind } from "@t3tools/contracts";
|
||||
import * as Clock from "effect/Clock";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -86,7 +87,7 @@ const make = Effect.gen(function* () {
|
||||
const floor = options?.allowReserve === true ? 1 : snapshot.limit * RESERVE_RATIO;
|
||||
if (snapshot.remaining >= floor) return;
|
||||
return yield* new SourceControlRateLimit.SourceControlRateLimitPausedError({
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
host: host.trim().toLowerCase(),
|
||||
retryAt: snapshot.resetAtMs,
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SourceControlProviderKind } from "@t3tools/contracts";
|
||||
import * as HostProcess from "@t3tools/shared/HostProcess";
|
||||
import { assert, describe, it } from "@effect/vitest";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
@@ -137,7 +138,11 @@ const makeProvider = (api: Partial<GitHubApi.GitHubApi["Service"]>) =>
|
||||
GitHubSourceControlProvider.make.pipe(Effect.provide(harness({ remotes: "", api }).layer));
|
||||
|
||||
const githubContext = (host: string) => ({
|
||||
provider: { kind: "github" as const, name: "GitHub", baseUrl: `https://${host}` },
|
||||
provider: {
|
||||
kind: SourceControlProviderKind.make("github"),
|
||||
name: "GitHub",
|
||||
baseUrl: `https://${host}`,
|
||||
},
|
||||
remoteName: "origin",
|
||||
remoteUrl: `git@${host}:acme/web.git`,
|
||||
});
|
||||
@@ -1067,7 +1072,7 @@ it.live.each([
|
||||
cwd: "/repo",
|
||||
context: {
|
||||
provider: {
|
||||
kind: "github" as const,
|
||||
kind: SourceControlProviderKind.make("github"),
|
||||
name: "GitHub Self-Hosted",
|
||||
baseUrl: "https://code.example.test",
|
||||
},
|
||||
@@ -1184,7 +1189,11 @@ it.effect.each([
|
||||
const input = {
|
||||
cwd: "/repo",
|
||||
context: {
|
||||
provider: { kind: "github" as const, name: "GitHub", baseUrl: `https://${host}` },
|
||||
provider: {
|
||||
kind: SourceControlProviderKind.make("github"),
|
||||
name: "GitHub",
|
||||
baseUrl: `https://${host}`,
|
||||
},
|
||||
remoteName: "origin",
|
||||
remoteUrl: `git@${host}:me/web.git`,
|
||||
},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SourceControlProviderKind } from "@t3tools/contracts";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Data from "effect/Data";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -62,7 +63,7 @@ const decodeLinkSubject = Schema.decodeUnknownEffect(
|
||||
);
|
||||
|
||||
function toChangeRequest(record: NormalizedGitHubPullRequestRecord): ChangeRequest {
|
||||
return { provider: "github", ...record };
|
||||
return { provider: SourceControlProviderKind.make("github"), ...record };
|
||||
}
|
||||
|
||||
function authAccounts(accounts: ReadonlyArray<GitHubAuthStatusAccount>) {
|
||||
@@ -164,7 +165,7 @@ export function parseGitHubAuth(
|
||||
|
||||
export const discovery = {
|
||||
type: "cli",
|
||||
kind: "github",
|
||||
kind: SourceControlProviderKind.make("github"),
|
||||
label: "GitHub",
|
||||
executable: "gh",
|
||||
versionArgs: ["--version"],
|
||||
@@ -271,7 +272,7 @@ export const makeDiscovery = Effect.gen(function* () {
|
||||
Effect.map((known) =>
|
||||
known
|
||||
? ({
|
||||
kind: "github",
|
||||
kind: SourceControlProviderKind.make("github"),
|
||||
name: "GitHub Self-Hosted",
|
||||
baseUrl: context.provider.baseUrl,
|
||||
} as const)
|
||||
@@ -878,7 +879,7 @@ export const make = Effect.gen(function* () {
|
||||
) =>
|
||||
(error: GitHubFailure) =>
|
||||
new SourceControlProviderError({
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
operation,
|
||||
cwd,
|
||||
...(context?.reference === undefined
|
||||
@@ -915,7 +916,7 @@ export const make = Effect.gen(function* () {
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new SourceControlProviderError({
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
operation: "resolveLink",
|
||||
cwd: input.cwd,
|
||||
detail: "The linked subject could not be read.",
|
||||
@@ -927,7 +928,7 @@ export const make = Effect.gen(function* () {
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new SourceControlProviderError({
|
||||
provider: "github",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
operation: "resolveLink.decode",
|
||||
cwd: input.cwd,
|
||||
detail: "The linked subject could not be read.",
|
||||
@@ -939,7 +940,7 @@ export const make = Effect.gen(function* () {
|
||||
});
|
||||
|
||||
return SourceControlProvider.SourceControlProvider.of({
|
||||
kind: "github",
|
||||
kind: SourceControlProviderKind.make("github"),
|
||||
// `gh pr list --head` filters on the head ref name alone and accepts anything, so an
|
||||
// `owner:branch` or `remote:branch` selector silently lists zero pull requests while
|
||||
// spending a GraphQL call; the bare branch is always among the selectors. Without the owner,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SourceControlProviderKind } from "@t3tools/contracts";
|
||||
/**
|
||||
* The GitHub driver: repository operations and discovery through `gh` and git, and pull requests
|
||||
* through the GitHub REST and GraphQL APIs.
|
||||
@@ -11,7 +12,7 @@ import * as GitHubPullRequestProvider from "./GitHubPullRequestProvider.ts";
|
||||
import * as GitHubSourceControlProvider from "./GitHubSourceControlProvider.ts";
|
||||
|
||||
export const driver = defineSourceControlDriver({
|
||||
kind: "github",
|
||||
kind: SourceControlProviderKind.make("github"),
|
||||
make: Effect.all({
|
||||
sourceControl: GitHubSourceControlProvider.make,
|
||||
discovery: GitHubSourceControlProvider.makeDiscovery,
|
||||
|
||||
Reference in new issue
Block a user