refactor(server): resolve title links through source control providers (#11844)
This commit is contained in:
1 parent
8b9f6d3d55
commit
08abda9dcf
17 files changed
+414
-113
No files matched your search
@@ -43,6 +43,7 @@ export interface SourceControlProviderHandle {
|
||||
export class SourceControlProviderRegistry extends Context.Service<
|
||||
SourceControlProviderRegistry,
|
||||
{
|
||||
readonly resolveLink: SourceControlProvider.ResolveSourceControlLink;
|
||||
readonly get: (
|
||||
kind: SourceControlProviderKind,
|
||||
) => Effect.Effect<
|
||||
@@ -161,6 +162,7 @@ function bindProviderContext(
|
||||
|
||||
return SourceControlProvider.SourceControlProvider.of({
|
||||
kind: provider.kind,
|
||||
...(provider.resolveLink ? { resolveLink: provider.resolveLink } : {}),
|
||||
listChangeRequests: (input) =>
|
||||
provider.listChangeRequests({
|
||||
...input,
|
||||
@@ -277,6 +279,13 @@ export const makeWithProviders = Effect.fn("makeSourceControlProviderRegistryWit
|
||||
);
|
||||
|
||||
return SourceControlProviderRegistry.of({
|
||||
resolveLink: (input) => {
|
||||
if (input.url.protocol !== "https:" || input.url.username || input.url.password) {
|
||||
return undefined;
|
||||
}
|
||||
const kind = detectSourceControlProviderFromRemoteUrl(input.url.href)?.kind;
|
||||
return kind ? providers.get(kind)?.resolveLink?.(input) : undefined;
|
||||
},
|
||||
get,
|
||||
resolveHandle,
|
||||
resolve: (input) => resolveHandle(input).pipe(Effect.map((handle) => handle.provider)),
|
||||
|
||||
Reference in new issue
Block a user