diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatPluginActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatPluginActions.ts index 734bc935c0e41..88ff9acfacba4 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatPluginActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatPluginActions.ts @@ -60,11 +60,11 @@ class InstallFromSourceAction extends Action2 { }); } - async run(accessor: ServicesAccessor): Promise { + async run(accessor: ServicesAccessor, args?: { source?: string; sha?: string }): Promise { const quickInputService = accessor.get(IQuickInputService); const pluginInstallService = accessor.get(IPluginInstallService); - const source = await quickInputService.input({ + const source = args?.source ?? await quickInputService.input({ placeHolder: localize('pluginSourcePlaceholder', "owner/repo or git clone URL"), prompt: localize('pluginSourcePrompt', "Enter a GitHub repository or git URL to install a plugin from"), }); @@ -73,7 +73,7 @@ class InstallFromSourceAction extends Action2 { return; } - await pluginInstallService.installPluginFromSource(source.trim()); + await pluginInstallService.installPluginFromSource(source.trim(), args?.sha); } } diff --git a/src/vs/workbench/contrib/chat/browser/pluginInstallService.ts b/src/vs/workbench/contrib/chat/browser/pluginInstallService.ts index 723f6087915cc..d8e84ecf1b92a 100644 --- a/src/vs/workbench/contrib/chat/browser/pluginInstallService.ts +++ b/src/vs/workbench/contrib/chat/browser/pluginInstallService.ts @@ -55,7 +55,7 @@ export class PluginInstallService implements IPluginInstallService { return this._installGitPlugin(plugin); } - async installPluginFromSource(source: string): Promise { + async installPluginFromSource(source: string, sha?: string): Promise { const reference = parseMarketplaceReference(source); if (!reference) { this._notificationService.notify({ @@ -75,8 +75,8 @@ export class PluginInstallService implements IPluginInstallService { // Build a source descriptor for the git clone. const sourceDescriptor = reference.kind === MarketplaceReferenceKind.GitHubShorthand - ? { kind: PluginSourceKind.GitHub as const, repo: reference.githubRepo! } - : { kind: PluginSourceKind.GitUrl as const, url: reference.cloneUrl }; + ? { kind: PluginSourceKind.GitHub as const, repo: reference.githubRepo!, sha } + : { kind: PluginSourceKind.GitUrl as const, url: reference.cloneUrl, sha }; // Build a temporary plugin object for the trust gate and clone step. const tempPlugin: IMarketplacePlugin = { diff --git a/src/vs/workbench/contrib/chat/common/plugins/pluginInstallService.ts b/src/vs/workbench/contrib/chat/common/plugins/pluginInstallService.ts index 22bddcd54a56d..750b903c06dd4 100644 --- a/src/vs/workbench/contrib/chat/common/plugins/pluginInstallService.ts +++ b/src/vs/workbench/contrib/chat/common/plugins/pluginInstallService.ts @@ -47,8 +47,11 @@ export interface IPluginInstallService { * GitHub shorthand (`owner/repo`) or a full git clone URL. Clones the * repository, reads marketplace metadata to discover plugins, and * registers the selected plugin. + * + * @param source A GitHub shorthand (`owner/repo`) or full git clone URL. + * @param sha Optional commit SHA to pin the installation to a specific revision. */ - installPluginFromSource(source: string): Promise; + installPluginFromSource(source: string, sha?: string): Promise; /** * Pulls the latest changes for an already-cloned marketplace repository.