mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
@@ -851,6 +851,11 @@
|
||||
"description": "%config.ignoreLegacyWarning%",
|
||||
"default": false
|
||||
},
|
||||
"git.ignoreMissingGitWarning": {
|
||||
"type": "boolean",
|
||||
"description": "%config.ignoreMissingGitWarning%",
|
||||
"default": false
|
||||
},
|
||||
"git.ignoreLimitWarning": {
|
||||
"type": "boolean",
|
||||
"description": "%config.ignoreLimitWarning%",
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
"config.countBadge": "Controls the git badge counter. `all` counts all changes. `tracked` counts only the tracked changes. `off` turns it off.",
|
||||
"config.checkoutType": "Controls what type of branches are listed when running `Checkout to...`. `all` shows all refs, `local` shows only the local branchs, `tags` shows only tags and `remote` shows only remote branches.",
|
||||
"config.ignoreLegacyWarning": "Ignores the legacy Git warning",
|
||||
"config.ignoreMissingGitWarning": "Ignores the warning when Git is missing",
|
||||
"config.ignoreLimitWarning": "Ignores the warning when there are too many changes in a repository",
|
||||
"config.defaultCloneDirectory": "The default location where to clone a git repository",
|
||||
"config.enableSmartCommit": "Commit all changes when there are no staged changes.",
|
||||
@@ -66,4 +67,4 @@
|
||||
"colors.untracked": "Color for untracked resources.",
|
||||
"colors.ignored": "Color for ignored resources.",
|
||||
"colors.conflict": "Color for resources with conflicts."
|
||||
}
|
||||
}
|
||||
@@ -1404,11 +1404,6 @@ export class CommandCenter {
|
||||
await repository.pushTo(choice, branchName, true);
|
||||
}
|
||||
|
||||
@command('git.showOutput')
|
||||
showOutput(): void {
|
||||
this.outputChannel.show();
|
||||
}
|
||||
|
||||
@command('git.ignore')
|
||||
async ignore(...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
if (resourceStates.length === 0 || !(resourceStates[0].resourceUri instanceof Uri)) {
|
||||
|
||||
@@ -131,7 +131,7 @@ function findGitWin32(onLookup: (path: string) => void): Promise<IGit> {
|
||||
}
|
||||
|
||||
export function findGit(hint: string | undefined, onLookup: (path: string) => void): Promise<IGit> {
|
||||
var first = hint ? findSpecificGit(hint, onLookup) : Promise.reject<IGit>(null);
|
||||
const first = hint ? findSpecificGit(hint, onLookup) : Promise.reject<IGit>(null);
|
||||
|
||||
return first
|
||||
.then(void 0, () => {
|
||||
|
||||
+43
-13
@@ -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';
|
||||
@@ -17,14 +17,11 @@ import { Askpass } from './askpass';
|
||||
import { toDisposable } from './util';
|
||||
import TelemetryReporter from 'vscode-extension-telemetry';
|
||||
|
||||
async function init(context: ExtensionContext, disposables: Disposable[]): Promise<void> {
|
||||
async function init(context: ExtensionContext, outputChannel: OutputChannel, disposables: Disposable[]): Promise<void> {
|
||||
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');
|
||||
@@ -61,18 +58,51 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
|
||||
await checkGitVersion(info);
|
||||
}
|
||||
|
||||
async function _activate(context: ExtensionContext, disposables: Disposable[]): Promise<any> {
|
||||
const outputChannel = window.createOutputChannel('Git');
|
||||
commands.registerCommand('git.showOutput', () => outputChannel.show());
|
||||
disposables.push(outputChannel);
|
||||
|
||||
try {
|
||||
await init(context, outputChannel, disposables);
|
||||
} catch (err) {
|
||||
if (!/Git installation not found/.test(err.message || '')) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.warn(err.message);
|
||||
outputChannel.appendLine(err.message);
|
||||
outputChannel.show();
|
||||
|
||||
const config = workspace.getConfiguration('git');
|
||||
const shouldIgnore = config.get<boolean>('ignoreMissingGitWarning') === true;
|
||||
|
||||
if (shouldIgnore) {
|
||||
return;
|
||||
}
|
||||
|
||||
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): any {
|
||||
const disposables: Disposable[] = [];
|
||||
context.subscriptions.push(new Disposable(() => Disposable.from(...disposables).dispose()));
|
||||
|
||||
init(context, disposables)
|
||||
.catch(err => {
|
||||
if (/Git installation not found/.test(err.message || '')) {
|
||||
console.warn(localize('notfound', "Git not found. You can configure its location with the `git.path` configuration setting."));
|
||||
} else {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
_activate(context, disposables)
|
||||
.catch(err => console.error(err));
|
||||
}
|
||||
|
||||
async function checkGitVersion(info: IGit): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user