Browse Source

Shows welcome page on first start

Fixes settings migration
main
Eric Amodio 6 years ago
parent
commit
79ef07d5d4
3 changed files with 31 additions and 26 deletions
  1. +2
    -0
      src/commands/common.ts
  2. +29
    -17
      src/extension.ts
  3. +0
    -9
      src/messages.ts

+ 2
- 0
src/commands/common.ts View File

@ -45,6 +45,8 @@ export enum Commands {
ShowQuickCurrentBranchHistory = 'gitlens.showQuickRepoHistory', ShowQuickCurrentBranchHistory = 'gitlens.showQuickRepoHistory',
ShowQuickRepoStatus = 'gitlens.showQuickRepoStatus', ShowQuickRepoStatus = 'gitlens.showQuickRepoStatus',
ShowQuickStashList = 'gitlens.showQuickStashList', ShowQuickStashList = 'gitlens.showQuickStashList',
ShowSettingsPage = 'gitlens.showSettingsPage',
ShowWelcomePage = 'gitlens.showWelcomePage',
StashApply = 'gitlens.stashApply', StashApply = 'gitlens.stashApply',
StashDelete = 'gitlens.stashDelete', StashDelete = 'gitlens.stashDelete',
StashSave = 'gitlens.stashSave', StashSave = 'gitlens.stashSave',

+ 29
- 17
src/extension.ts View File

@ -1,9 +1,9 @@
'use strict'; 'use strict';
import { Objects, Versions } from './system'; import { Objects, Versions } from './system';
import { ConfigurationTarget, ExtensionContext, extensions, window, workspace } from 'vscode';
import { commands, ConfigurationTarget, ExtensionContext, extensions, window, workspace } from 'vscode';
import { CodeLensLanguageScope, CodeLensScopes, configuration, Configuration, IConfig } from './configuration'; import { CodeLensLanguageScope, CodeLensScopes, configuration, Configuration, IConfig } from './configuration';
import { CommandContext, ExtensionKey, GlobalState, QualifiedExtensionId, setCommandContext } from './constants'; import { CommandContext, ExtensionKey, GlobalState, QualifiedExtensionId, setCommandContext } from './constants';
import { configureCommands } from './commands';
import { Commands, configureCommands } from './commands';
import { Container } from './container'; import { Container } from './container';
import { GitService } from './gitService'; import { GitService } from './gitService';
import { Logger } from './logger'; import { Logger } from './logger';
@ -46,6 +46,10 @@ export async function activate(context: ExtensionContext) {
return; return;
} }
Container.initialize(context, cfg);
configureCommands();
const gitVersion = GitService.getGitVersion(); const gitVersion = GitService.getGitVersion();
// Telemetry.configure(ApplicationInsightsKey); // Telemetry.configure(ApplicationInsightsKey);
@ -55,15 +59,11 @@ export async function activate(context: ExtensionContext) {
// telemetryContext['git.version'] = gitVersion; // telemetryContext['git.version'] = gitVersion;
// Telemetry.setContext(telemetryContext); // Telemetry.setContext(telemetryContext);
notifyOnUnsupportedGitVersion(context, gitVersion);
notifyOnNewGitLensVersion(context, gitlensVersion, previousVersion);
notifyOnUnsupportedGitVersion(gitVersion);
notifyOnNewGitLensVersion(gitlensVersion, previousVersion);
context.globalState.update(GlobalState.GitLensVersion, gitlensVersion); context.globalState.update(GlobalState.GitLensVersion, gitlensVersion);
Container.initialize(context, cfg);
configureCommands();
// Constantly over my data cap so stop collecting initialized event // Constantly over my data cap so stop collecting initialized event
// Telemetry.trackEvent('initialized', Objects.flatten(cfg, 'config', true)); // Telemetry.trackEvent('initialized', Objects.flatten(cfg, 'config', true));
@ -120,7 +120,12 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin
await configuration.migrate('gitExplorer.gravatarsDefault', configuration.name('defaultGravatarsStyle').value); await configuration.migrate('gitExplorer.gravatarsDefault', configuration.name('defaultGravatarsStyle').value);
} }
if (Versions.compare(previous, Versions.from(8, 0, 0, 'beta')) !== 1) {
if (Versions.compare(previous, Versions.from(7, 5, 9)) !== 1) {
const section = configuration.name('advanced')('messages').value;
const messages = configuration.get<{ [key: string]: boolean }>(section);
messages[SuppressedMessages.WelcomeNotice] = false;
await configuration.update(section, messages, ConfigurationTarget.Global);
await configuration.migrate('annotations.file.gutter.gravatars', configuration.name('blame')('avatars').value); await configuration.migrate('annotations.file.gutter.gravatars', configuration.name('blame')('avatars').value);
await configuration.migrate('annotations.file.gutter.compact', configuration.name('blame')('compact').value); await configuration.migrate('annotations.file.gutter.compact', configuration.name('blame')('compact').value);
await configuration.migrate('annotations.file.gutter.dateFormat', configuration.name('blame')('dateFormat').value); await configuration.migrate('annotations.file.gutter.dateFormat', configuration.name('blame')('dateFormat').value);
@ -174,19 +179,26 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin
} }
} }
async function notifyOnNewGitLensVersion(context: ExtensionContext, version: string, previousVersion: string | undefined) {
if (configuration.get<boolean>(configuration.name('advanced')('messages')(SuppressedMessages.UpdateNotice).value)) return;
async function notifyOnNewGitLensVersion(version: string, previousVersion: string | undefined) {
if (previousVersion === undefined) { if (previousVersion === undefined) {
Logger.log(`GitLens first-time install`); Logger.log(`GitLens first-time install`);
await Messages.showWelcomeMessage();
}
else if (previousVersion !== version) {
Logger.log(`GitLens upgraded from v${previousVersion} to v${version}`);
}
if (!Container.config.advanced.messages.suppressWelcomeNotice) {
const section = configuration.name('advanced')('messages').value;
const messages = configuration.get<{ [key: string]: boolean }>(section);
messages[SuppressedMessages.WelcomeNotice] = true;
await configuration.update(section, messages, ConfigurationTarget.Global);
await commands.executeCommand(Commands.ShowWelcomePage);
return; return;
} }
if (previousVersion !== version) {
Logger.log(`GitLens upgraded from v${previousVersion} to v${version}`);
}
if (previousVersion === undefined || Container.config.advanced.messages.suppressUpdateNotice) return;
const [major, minor] = version.split('.'); const [major, minor] = version.split('.');
const [prevMajor, prevMinor] = previousVersion.split('.'); const [prevMajor, prevMinor] = previousVersion.split('.');
@ -197,7 +209,7 @@ async function notifyOnNewGitLensVersion(context: ExtensionContext, version: str
await Messages.showUpdateMessage(version); await Messages.showUpdateMessage(version);
} }
async function notifyOnUnsupportedGitVersion(context: ExtensionContext, version: string) {
async function notifyOnUnsupportedGitVersion(version: string) {
if (GitService.validateGitVersion(2, 2)) return; if (GitService.validateGitVersion(2, 2)) return;
// If git is less than v2.2.0 // If git is less than v2.2.0

+ 0
- 9
src/messages.ts View File

@ -57,15 +57,6 @@ export class Messages {
return result; return result;
} }
static async showWelcomeMessage(): Promise<string | undefined> {
const viewDocs = 'View Docs';
const result = await Messages.showMessage('info', `Thank you for choosing GitLens! GitLens is powerful, feature rich, and highly configurable, so please be sure to view the docs and tailor it to suit your needs`, SuppressedMessages.WelcomeNotice, null, viewDocs);
if (result === viewDocs) {
commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://marketplace.visualstudio.com/items/eamodio.gitlens'));
}
return result;
}
private static async showMessage(type: 'info' | 'warn' | 'error', message: string, suppressionKey: SuppressedMessages, dontShowAgain: string | null = 'Don\'t Show Again', ...actions: any[]): Promise<string | undefined> { private static async showMessage(type: 'info' | 'warn' | 'error', message: string, suppressionKey: SuppressedMessages, dontShowAgain: string | null = 'Don\'t Show Again', ...actions: any[]): Promise<string | undefined> {
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain})`); Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain})`);

Loading…
Cancel
Save