Revert "Merge from vscode merge-base (#22769)" (#22779)

This reverts commit 6bd0a17d3c.
This commit is contained in:
Karl Burtram
2023-04-18 21:44:05 -07:00
committed by GitHub
parent 6bd0a17d3c
commit 47a1745180
2389 changed files with 42588 additions and 92170 deletions

View File

@@ -6,14 +6,14 @@
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
import { ExtensionContext, workspace, Disposable, commands } from 'vscode';
import { ExtensionContext, workspace, window, Disposable, commands, OutputChannel } from 'vscode';
import { findGit, Git } from './git';
import { Model } from './model';
import { CommandCenter } from './commands';
import { GitFileSystemProvider } from './fileSystemProvider';
import { GitDecorations } from './decorationProvider';
import { Askpass } from './askpass';
import { toDisposable, filterEvent, eventToPromise } from './util';
import { toDisposable, filterEvent, eventToPromise, logTimestamp } from './util';
import TelemetryReporter from '@vscode/extension-telemetry';
import { GitExtension } from './api/git';
import { GitProtocolHandler } from './protocolHandler';
@@ -24,9 +24,6 @@ import * as os from 'os';
import { GitTimelineProvider } from './timelineProvider';
import { registerAPICommands } from './api/api1';
import { TerminalEnvironmentManager } from './terminal';
import { OutputChannelLogger } from './log';
import { createIPCServer, IPCServer } from './ipc/ipcServer';
import { GitEditor } from './gitEditor';
const deactivateTasks: { (): Promise<any> }[] = [];
@@ -36,7 +33,7 @@ export async function deactivate(): Promise<any> {
}
}
async function createModel(context: ExtensionContext, outputChannelLogger: OutputChannelLogger, telemetryReporter: TelemetryReporter, disposables: Disposable[]): Promise<Model> {
async function createModel(context: ExtensionContext, outputChannel: OutputChannel, telemetryReporter: TelemetryReporter, disposables: Disposable[]): Promise<Model> {
const pathValue = workspace.getConfiguration('git').get<string | string[]>('path');
let pathHints = Array.isArray(pathValue) ? pathValue : pathValue ? [pathValue] : [];
@@ -49,7 +46,7 @@ async function createModel(context: ExtensionContext, outputChannelLogger: Outpu
}
const info = await findGit(pathHints, gitPath => {
outputChannelLogger.logInfo(localize('validating', "Validating found git in: {0}", gitPath));
outputChannel.appendLine(localize('validating', "{0} Validating found git in: {1}", logTimestamp(), gitPath));
if (excludes.length === 0) {
return true;
}
@@ -57,30 +54,18 @@ async function createModel(context: ExtensionContext, outputChannelLogger: Outpu
const normalized = path.normalize(gitPath).replace(/[\r\n]+$/, '');
const skip = excludes.some(e => normalized.startsWith(e));
if (skip) {
outputChannelLogger.logInfo(localize('skipped', "Skipped found git in: {0}", gitPath));
outputChannel.appendLine(localize('skipped', "{0} Skipped found git in: {1}", logTimestamp(), gitPath));
}
return !skip;
});
let ipcServer: IPCServer | undefined = undefined;
try {
ipcServer = await createIPCServer(context.storagePath);
} catch (err) {
outputChannelLogger.logError(`Failed to create git IPC: ${err}`);
}
const askpass = new Askpass(ipcServer);
const askpass = await Askpass.create(outputChannel, context.storagePath);
disposables.push(askpass);
const gitEditor = new GitEditor(ipcServer);
disposables.push(gitEditor);
const environment = { ...askpass.getEnv(), ...gitEditor.getEnv(), ...ipcServer?.getEnv() };
const terminalEnvironmentManager = new TerminalEnvironmentManager(context, [askpass, gitEditor, ipcServer]);
const environment = askpass.getEnv();
const terminalEnvironmentManager = new TerminalEnvironmentManager(context, environment);
disposables.push(terminalEnvironmentManager);
outputChannelLogger.logInfo(localize('using git', "Using git {0} from {1}", info.version, info.path));
const git = new Git({
gitPath: info.path,
@@ -88,7 +73,7 @@ async function createModel(context: ExtensionContext, outputChannelLogger: Outpu
version: info.version,
env: environment,
});
const model = new Model(git, askpass, context.globalState, outputChannelLogger, telemetryReporter);
const model = new Model(git, askpass, context.globalState, outputChannel, telemetryReporter);
disposables.push(model);
const onRepository = () => commands.executeCommand('setContext', 'gitOpenRepositoryCount', `${model.repositories.length}`);
@@ -96,6 +81,8 @@ async function createModel(context: ExtensionContext, outputChannelLogger: Outpu
model.onDidCloseRepository(onRepository, null, disposables);
onRepository();
outputChannel.appendLine(localize('using git', "{0} Using git {1} from {2}", logTimestamp(), info.version, info.path));
const onOutput = (str: string) => {
const lines = str.split(/\r?\n/mg);
@@ -103,12 +90,12 @@ async function createModel(context: ExtensionContext, outputChannelLogger: Outpu
lines.pop();
}
outputChannelLogger.log(lines.join('\n'));
outputChannel.appendLine(`${logTimestamp()} ${lines.join('\n')}`);
};
git.onOutput.addListener('log', onOutput);
disposables.push(toDisposable(() => git.onOutput.removeListener('log', onOutput)));
const cc = new CommandCenter(git, model, outputChannelLogger, telemetryReporter);
const cc = new CommandCenter(git, model, outputChannel, telemetryReporter);
disposables.push(
cc,
new GitFileSystemProvider(model),
@@ -117,9 +104,6 @@ async function createModel(context: ExtensionContext, outputChannelLogger: Outpu
new GitTimelineProvider(model, cc)
);
// const postCommitCommandsProvider = new GitPostCommitCommandsProvider(); {{SQL CARBON TODO}} lewissanchez - Do we need this?
// model.registerPostCommitCommandsProvider(postCommitCommandsProvider); {{SQL CARBON TODO}} lewissanchez - Do we need this?
// checkGitVersion(info); {{SQL CARBON EDIT}} Don't check git version
return model;
@@ -178,8 +162,9 @@ export async function _activate(context: ExtensionContext): Promise<GitExtension
const disposables: Disposable[] = [];
context.subscriptions.push(new Disposable(() => Disposable.from(...disposables).dispose()));
const outputChannelLogger = new OutputChannelLogger();
disposables.push(outputChannelLogger);
const outputChannel = window.createOutputChannel('Git');
commands.registerCommand('git.showOutput', () => outputChannel.show());
disposables.push(outputChannel);
const { name, version, aiKey } = require('../package.json') as { name: string; version: string; aiKey: string };
const telemetryReporter = new TelemetryReporter(name, version, aiKey);
@@ -193,12 +178,12 @@ export async function _activate(context: ExtensionContext): Promise<GitExtension
const onEnabled = filterEvent(onConfigChange, () => workspace.getConfiguration('git', null).get<boolean>('enabled') === true);
const result = new GitExtensionImpl();
eventToPromise(onEnabled).then(async () => result.model = await createModel(context, outputChannelLogger, telemetryReporter, disposables));
eventToPromise(onEnabled).then(async () => result.model = await createModel(context, outputChannel, telemetryReporter, disposables));
return result;
}
try {
const model = await createModel(context, outputChannelLogger, telemetryReporter, disposables);
const model = await createModel(context, outputChannel, telemetryReporter, disposables);
return new GitExtensionImpl(model);
} catch (err) {
if (!/Git installation not found/.test(err.message || '')) {
@@ -209,9 +194,7 @@ export async function _activate(context: ExtensionContext): Promise<GitExtension
// outputChannel.appendLine(err.message); {{SQL CARBON EDIT}} turn-off Git missing prompt
/* __GDPR__
"git.missing" : {
"owner": "lszomoru"
}
"git.missing" : {}
*/
telemetryReporter.sendTelemetryEvent('git.missing');