diff --git a/extensions/git/package.json b/extensions/git/package.json index a1748f0d2f6..b06bb33a1db 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -613,6 +613,11 @@ ], "description": "%config.checkoutType%", "default": "all" + }, + "git.ignoreLegacyWarning": { + "type": "boolean", + "description": "%config.ignoreLegacyWarning%", + "default": false } } } diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index 01ed8caaa51..1db12e4a6b0 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -35,5 +35,6 @@ "config.enableLongCommitWarning": "Whether long commit messages should be warned about", "config.confirmSync": "Confirm before synchronizing git repositories", "config.countBadge": "Controls the git badge counter", - "config.checkoutType": "Controls what type of branches are listed" + "config.checkoutType": "Controls what type of branches are listed", + "config.ignoreLegacyWarning": "Ignores the legacy Git warning" } \ No newline at end of file diff --git a/extensions/git/src/main.ts b/extensions/git/src/main.ts index 537277792de..eeb70ba6948 100644 --- a/extensions/git/src/main.ts +++ b/extensions/git/src/main.ts @@ -6,7 +6,7 @@ 'use strict'; import { ExtensionContext, workspace, window, Disposable, commands, Uri } from 'vscode'; -import { findGit, Git } from './git'; +import { findGit, Git, IGit } from './git'; import { Model } from './model'; import { GitSCMProvider } from './scmProvider'; import { CommandCenter } from './commands'; @@ -65,27 +65,7 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi model ); - const IgnoreOldGitStorageKey = 'settings.extension.git.ignoreOld'; - - // Check user setting to show older version message - if (!context.globalState.get(IgnoreOldGitStorageKey)) { - if (/^[01]/.test(info.version)) { - const update = localize('updateGit', "Update Git"); - const neverShowAgain = localize('neverShowAgain', "Don't show again"); - - const choice = await window.showWarningMessage( - localize('git20', "You seem to have git {0} installed. Code works best with git >= 2", info.version), - update, - neverShowAgain - ); - - if (choice === update) { - commands.executeCommand('vscode.open', Uri.parse('https://git-scm.com/')); - } else if (choice === neverShowAgain) { - context.globalState.update(IgnoreOldGitStorageKey, true); - } - } - } + await checkGitVersion(info); } export function activate(context: ExtensionContext): any { @@ -94,4 +74,32 @@ export function activate(context: ExtensionContext): any { init(context, disposables) .catch(err => console.error(err)); +} + +async function checkGitVersion(info: IGit): Promise { + const config = workspace.getConfiguration('git'); + const shouldIgnore = config.get('ignoreLegacyWarning') === true; + + if (shouldIgnore) { + return; + } + + if (!/^[01]/.test(info.version)) { + return; + } + + const update = localize('updateGit', "Update Git"); + const neverShowAgain = localize('neverShowAgain', "Don't show again"); + + const choice = await window.showWarningMessage( + localize('git20', "You seem to have git {0} installed. Code works best with git >= 2", info.version), + update, + neverShowAgain + ); + + if (choice === update) { + commands.executeCommand('vscode.open', Uri.parse('https://git-scm.com/')); + } else if (choice === neverShowAgain) { + await config.update('ignoreLegacyWarning', true, true); + } } \ No newline at end of file