mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 02:32:35 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.config(process.env.VSCODE_NLS_CONFIG)();
|
||||
import { ExtensionContext, workspace, window, Disposable, commands, Uri } from 'vscode';
|
||||
import { ExtensionContext, workspace, window, Disposable, commands, Uri, OutputChannel } from 'vscode';
|
||||
import { findGit, Git, IGit } from './git';
|
||||
import { Model } from './model';
|
||||
import { CommandCenter } from './commands';
|
||||
@@ -16,23 +16,19 @@ import { GitDecorations } from './decorationProvider';
|
||||
import { Askpass } from './askpass';
|
||||
import { toDisposable } from './util';
|
||||
import TelemetryReporter from 'vscode-extension-telemetry';
|
||||
import { API, createApi } from './api';
|
||||
|
||||
async function init(context: ExtensionContext, disposables: Disposable[]): Promise<void> {
|
||||
async function init(context: ExtensionContext, outputChannel: OutputChannel, disposables: Disposable[]): Promise<Model> {
|
||||
const { name, version, aiKey } = require(context.asAbsolutePath('./package.json')) as { name: string, version: string, aiKey: string };
|
||||
const telemetryReporter: TelemetryReporter = new TelemetryReporter(name, version, aiKey);
|
||||
disposables.push(telemetryReporter);
|
||||
|
||||
const outputChannel = window.createOutputChannel('Git');
|
||||
disposables.push(outputChannel);
|
||||
|
||||
const config = workspace.getConfiguration('git');
|
||||
const enabled = config.get<boolean>('enabled') === true;
|
||||
const pathHint = workspace.getConfiguration('git').get<string>('path');
|
||||
const info = await findGit(pathHint);
|
||||
const info = await findGit(pathHint, path => outputChannel.appendLine(localize('looking', "Looking for git in: {0}", path)));
|
||||
const askpass = new Askpass();
|
||||
const env = await askpass.getEnv();
|
||||
const git = new Git({ gitPath: info.path, version: info.version, env });
|
||||
const model = new Model(git);
|
||||
const model = new Model(git, context.globalState);
|
||||
disposables.push(model);
|
||||
|
||||
const onRepository = () => commands.executeCommand('setContext', 'gitOpenRepositoryCount', `${model.repositories.length}`);
|
||||
@@ -40,15 +36,9 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
|
||||
model.onDidCloseRepository(onRepository, null, disposables);
|
||||
onRepository();
|
||||
|
||||
if (!enabled) {
|
||||
const commandCenter = new CommandCenter(git, model, outputChannel, telemetryReporter);
|
||||
disposables.push(commandCenter);
|
||||
return;
|
||||
}
|
||||
|
||||
outputChannel.appendLine(localize('using git', "Using git {0} from {1}", info.version, info.path));
|
||||
|
||||
const onOutput = str => outputChannel.append(str);
|
||||
const onOutput = (str: string) => outputChannel.append(str);
|
||||
git.onOutput.addListener('log', onOutput);
|
||||
disposables.push(toDisposable(() => git.onOutput.removeListener('log', onOutput)));
|
||||
|
||||
@@ -59,14 +49,58 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
|
||||
);
|
||||
|
||||
await checkGitVersion(info);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
export function activate(context: ExtensionContext): any {
|
||||
async function _activate(context: ExtensionContext, disposables: Disposable[]): Promise<Model | undefined> {
|
||||
const outputChannel = window.createOutputChannel('Git');
|
||||
commands.registerCommand('git.showOutput', () => outputChannel.show());
|
||||
disposables.push(outputChannel);
|
||||
|
||||
try {
|
||||
return await init(context, outputChannel, disposables);
|
||||
} catch (err) {
|
||||
if (!/Git installation not found/.test(err.message || '')) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
const config = workspace.getConfiguration('git');
|
||||
const shouldIgnore = config.get<boolean>('ignoreMissingGitWarning') === true;
|
||||
|
||||
if (shouldIgnore) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.warn(err.message);
|
||||
outputChannel.appendLine(err.message);
|
||||
outputChannel.show();
|
||||
|
||||
const download = localize('downloadgit', "Download Git");
|
||||
const neverShowAgain = localize('neverShowAgain', "Don't show again");
|
||||
const choice = await window.showWarningMessage(
|
||||
localize('notfound', "Git not found. Install it or configure it using the 'git.path' setting."),
|
||||
download,
|
||||
neverShowAgain
|
||||
);
|
||||
|
||||
if (choice === download) {
|
||||
commands.executeCommand('vscode.open', Uri.parse('https://git-scm.com/'));
|
||||
} else if (choice === neverShowAgain) {
|
||||
await config.update('ignoreMissingGitWarning', true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function activate(context: ExtensionContext): API {
|
||||
const disposables: Disposable[] = [];
|
||||
context.subscriptions.push(new Disposable(() => Disposable.from(...disposables).dispose()));
|
||||
|
||||
init(context, disposables)
|
||||
.catch(err => console.error(err));
|
||||
const activatePromise = _activate(context, disposables);
|
||||
const modelPromise = activatePromise.then(model => model || Promise.reject<Model>('Git model not found'));
|
||||
activatePromise.catch(err => console.error(err));
|
||||
|
||||
return createApi(modelPromise);
|
||||
}
|
||||
|
||||
async function checkGitVersion(info: IGit): Promise<void> {
|
||||
@@ -102,5 +136,6 @@ async function checkGitVersion(info: IGit): Promise<void> {
|
||||
} else if (choice === neverShowAgain) {
|
||||
await config.update('ignoreLegacyWarning', true, true);
|
||||
}
|
||||
// {{SQL CARBON EDIT}}
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user