Browse Source

Adds update notification

Adds don't show again option to invalid git version notification
main
Eric Amodio 7 years ago
parent
commit
5a0a2f3b61
3 changed files with 50 additions and 13 deletions
  1. +2
    -0
      CHANGELOG.md
  2. +5
    -2
      src/constants.ts
  3. +43
    -11
      src/extension.ts

+ 2
- 0
CHANGELOG.md View File

@ -1,6 +1,7 @@
## Release Notes
### 2.13.0
- Adds an update notification (for feature releases) -- please file an issue if this it too much
- Adds `Show Branch History` command (`gitlens.showQuickBranchHistory`) to show the history of the selected branch
- Adds `Show Last Opened Quick Pick` command (`gitlens.showLastQuickPick`) to re-open the previously opened quick pick - helps to get back to previous context
- Adds `alt+-` shortcut for the `Show Last Opened Quick Pick` command (`gitlens.showLastQuickPick`)
@ -13,6 +14,7 @@
- Adds current branch to branch quick pick placeholder
- Adds `Show Branch History` command to the branch history quick pick when showing only limited commits (e.g. starting at a specified commit)
- Adds `Show File History` command to the file history quick pick when showing only limited commits (e.g. starting at a specified commit)
- Adds `Don't Show Again` option to the unsupported git version notification
- Changes `Show Repository History` command to `Show Current Branch History`
- Changes `Repository History` terminology to `Branch History`
- Fixes issue with `gitlens.diffWithPrevious` command execution via CodeLens when the CodeLens was not at the document/file level

+ 5
- 2
src/constants.ts View File

@ -2,7 +2,7 @@
export const RepoPath = 'repoPath';
export type BuiltInCommands = 'cursorMove' | 'editor.action.showReferences' | 'editor.action.toggleRenderWhitespace' | 'editorScroll' | 'revealLine' | 'setContext' | 'vscode.diff' | 'vscode.executeDocumentSymbolProvider' | 'vscode.executeCodeLensProvider' | 'vscode.open' | 'workbench.action.closeActiveEditor' | 'workbench.action.nextEditor';
export type BuiltInCommands = 'cursorMove' | 'editor.action.showReferences' | 'editor.action.toggleRenderWhitespace' | 'editorScroll' | 'revealLine' | 'setContext' | 'vscode.diff' | 'vscode.executeDocumentSymbolProvider' | 'vscode.executeCodeLensProvider' | 'vscode.open' | 'vscode.previewHtml' | 'workbench.action.closeActiveEditor' | 'workbench.action.nextEditor';
export const BuiltInCommands = {
CloseActiveEditor: 'workbench.action.closeActiveEditor' as BuiltInCommands,
CursorMove: 'cursorMove' as BuiltInCommands,
@ -12,6 +12,7 @@ export const BuiltInCommands = {
ExecuteCodeLensProvider: 'vscode.executeCodeLensProvider' as BuiltInCommands,
Open: 'vscode.open' as BuiltInCommands,
NextEditor: 'workbench.action.nextEditor' as BuiltInCommands,
PreviewHtml: 'vscode.previewHtml' as BuiltInCommands,
RevealLine: 'revealLine' as BuiltInCommands,
SetContext: 'setContext' as BuiltInCommands,
ShowReferences: 'editor.action.showReferences' as BuiltInCommands,
@ -27,5 +28,7 @@ export const DocumentSchemes = {
export type WorkspaceState = 'repoPath';
export const WorkspaceState = {
RepoPath: 'repoPath' as WorkspaceState
GitLensVersion: 'gitlensVersion' as WorkspaceState,
RepoPath: 'repoPath' as WorkspaceState,
SuppressGitVersionWarning: 'suppressGitVersionWarning' as WorkspaceState
};

+ 43
- 11
src/extension.ts View File

@ -1,5 +1,5 @@
'use strict';
import { ExtensionContext, languages, window, workspace } from 'vscode';
import { commands, ExtensionContext, extensions, languages, Uri, window, workspace } from 'vscode';
import { BlameabilityTracker } from './blameabilityTracker';
import { BlameActiveLineController } from './blameActiveLineController';
import { BlameAnnotationController } from './blameAnnotationController';
@ -14,7 +14,7 @@ import { ShowLastQuickPickCommand, ShowQuickBranchHistoryCommand, ShowQuickCurre
import { ToggleCodeLensCommand } from './commands';
import { Keyboard } from './commands';
import { IAdvancedConfig, IBlameConfig } from './configuration';
import { WorkspaceState } from './constants';
import { BuiltInCommands, WorkspaceState } from './constants';
import { GitContentProvider } from './gitContentProvider';
import { Git, GitService } from './gitService';
import { GitRevisionCodeLensProvider } from './gitRevisionCodeLensProvider';
@ -24,15 +24,18 @@ import { Logger } from './logger';
export async function activate(context: ExtensionContext) {
Logger.configure(context);
const gitlens = extensions.getExtension('eamodio.gitlens');
const gitlensVersion = gitlens.packageJSON.version;
// Workspace not using a folder. No access to git repo.
if (!workspace.rootPath) {
Logger.warn('GitLens inactive: no rootPath');
Logger.warn(`GitLens(v${gitlensVersion}) inactive: no rootPath`);
return;
}
const rootPath = workspace.rootPath.replace(/\\/g, '/');
Logger.log(`GitLens active: ${rootPath}`);
Logger.log(`GitLens(v${gitlensVersion}) active: ${rootPath}`);
const config = workspace.getConfiguration('gitlens');
const gitPath = config.get<IAdvancedConfig>('advanced').git;
@ -52,12 +55,11 @@ export async function activate(context: ExtensionContext) {
return;
}
const version = Git.gitInfo().version;
const [major, minor] = version.split('.');
// If git is less than v2.2.0
if (parseInt(major, 10) < 2 || parseInt(minor, 10) < 2) {
await window.showErrorMessage(`GitLens requires a newer version of Git (>= 2.2.0) than is currently installed (${version}). Please install a more recent version of Git.`);
}
const gitVersion = Git.gitInfo().version;
Logger.log(`Git version: ${gitVersion}`);
notifyOnUnsupportedGitVersion(context, gitVersion);
notifyOnNewGitLensVersion(context, gitlensVersion);
let gitEnabled = workspace.getConfiguration('git').get<boolean>('enabled');
setCommandContext(CommandContext.Enabled, gitEnabled);
@ -114,4 +116,34 @@ export async function activate(context: ExtensionContext) {
}
// this method is called when your extension is deactivated
export function deactivate() { }
export function deactivate() { }
async function notifyOnNewGitLensVersion(context: ExtensionContext, version: string) {
const previousVersion = context.globalState.get<string>(WorkspaceState.GitLensVersion);
await context.globalState.update(WorkspaceState.GitLensVersion, version);
if (previousVersion) {
const [major, minor] = version.split('.');
const [prevMajor, prevMinor] = previousVersion.split('.');
if (major === prevMajor && minor === prevMinor) return;
}
const result = await window.showInformationMessage(`GitLens has been updated to v${version}`, 'View Release Notes');
if (result === 'View Release Notes') {
commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://marketplace.visualstudio.com/items/eamodio.gitlens/changelog'));
}
}
async function notifyOnUnsupportedGitVersion(context: ExtensionContext, version: string) {
if (context.globalState.get(WorkspaceState.SuppressGitVersionWarning, false)) return;
const [major, minor] = version.split('.');
// If git is less than v2.2.0
if (parseInt(major, 10) < 2 || parseInt(minor, 10) < 2) {
const result = await window.showErrorMessage(`GitLens requires a newer version of Git (>= 2.2.0) than is currently installed (${version}). Please install a more recent version of Git.`, `Don't Show Again`);
if (result === `Don't Show Again`) {
context.globalState.update(WorkspaceState.SuppressGitVersionWarning, true);
}
}
}

Loading…
Cancel
Save