Merge pull request #184413 from microsoft/tyriar/184331

Adopt EnvironmentVariableCollection in git ext
This commit is contained in:
Daniel Imms
2023-06-08 08:52:35 -07:00
committed by GitHub
3 changed files with 13 additions and 1 deletions

View File

@@ -18,6 +18,8 @@ export class Askpass implements IIPCHandler, ITerminalEnvironmentProvider {
private cache = new Map<string, Credentials>();
private credentialsProviders = new Set<CredentialsProvider>();
readonly featureDescription = 'git auth provider';
constructor(private ipc?: IIPCServer) {
if (ipc) {
this.disposable = ipc.registerHandler('askpass', this);

View File

@@ -17,6 +17,8 @@ export class GitEditor implements IIPCHandler, ITerminalEnvironmentProvider {
private env: { [key: string]: string };
private disposable: IDisposable = EmptyDisposable;
readonly featureDescription = 'git editor';
constructor(ipc?: IIPCServer) {
if (ipc) {
this.disposable = ipc.registerHandler('git-editor', this);

View File

@@ -3,10 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ExtensionContext, workspace } from 'vscode';
import { ExtensionContext, l10n, workspace } from 'vscode';
import { filterEvent, IDisposable } from './util';
export interface ITerminalEnvironmentProvider {
featureDescription?: string;
getTerminalEnv(): { [key: string]: string };
}
@@ -29,12 +30,19 @@ export class TerminalEnvironmentManager {
return;
}
const features: string[] = [];
for (const envProvider of this.envProviders) {
const terminalEnv = envProvider?.getTerminalEnv() ?? {};
for (const name of Object.keys(terminalEnv)) {
this.context.environmentVariableCollection.replace(name, terminalEnv[name]);
}
if (envProvider?.featureDescription && Object.keys(terminalEnv).length > 0) {
features.push(envProvider.featureDescription);
}
}
if (features.length) {
this.context.environmentVariableCollection.description = l10n.t('Enables the following features: {0}', features.join(', '));
}
}