Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ export const makeDiscovery = Effect.gen(function* () {
refineUnknownRemote: ({ context }) => {
const url = URL.parse(context.provider.baseUrl);
if (!url?.host) return Effect.succeed(null);
const host = gitHubApiHostForRemote(context.remoteUrl) ?? url.host;
// A timeout or keyring failure propagates: the registry does not keep that answer.
return api.credential(url.host).pipe(
return api.credential(host).pipe(
Effect.as(true),
Effect.catchTags({
GitHubCliMissingError: () => Effect.succeed(false),
Expand All @@ -320,8 +321,8 @@ export const makeDiscovery = Effect.gen(function* () {
known
? ({
kind: SourceControlProviderKind.make("github"),
name: "GitHub Self-Hosted",
baseUrl: context.provider.baseUrl,
name: host === "github.com" ? "GitHub" : "GitHub Self-Hosted",
baseUrl: host === url.host ? context.provider.baseUrl : `https://${host}`,
} as const)
: null,
),
Expand Down
25 changes: 25 additions & 0 deletions packages/source-control-github/src/server/gitHubDiscovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,31 @@ it.effect("asks for no credential when the identity resolver left the base URL e
}),
);

it.effect.each([
["github-work", "git@github-work:team/project.git"],
["github-ci", "git@github-ci:team/project.git"],
["github-work", "ssh://git@github-work:22/team/project.git"],
["github.com-work", "git@github.com-work:team/project.git"],
] as const)("recognizes a GitHub SSH alias on %s (%s)", ([host, remoteUrl]) =>
Effect.gen(function* () {
const discovery = yield* makeDiscovery((host) =>
host === "github.com"
? Effect.succeed({ token: Redacted.make("token"), fingerprint: `${host}:fingerprint` })
: Effect.fail(new GitHubCredentials.GitHubNotSignedInError({ host })),
);
if (discovery.type !== "managed-cli") return assert.fail("expected a managed CLI");
const provider = yield* discovery.refineUnknownRemote({
cwd: "/repo",
context: { ...unknownContext(`https://${host}`), remoteUrl },
});
assert.deepStrictEqual(provider, {
kind: SourceControlProviderKind.make("github"),
name: "GitHub",
baseUrl: "https://github.com",
});
}),
);

const decodeSettings = Schema.decodeSync(ServerSettings);
const referencedTokenSettings = decodeSettings({
sourceControlHosts: {
Expand Down
Loading