Procházet zdrojové kódy

Adds expiration to insiders builds

main
Eric Amodio před 2 roky
rodič
revize
3b42557e6d
2 změnil soubory, kde provedl 31 přidání a 3 odebrání
  1. +24
    -2
      src/extension.ts
  2. +7
    -1
      src/messages.ts

+ 24
- 2
src/extension.ts Zobrazit soubor

@ -12,14 +12,19 @@ import { isGitUri } from './git/gitUri';
import { getBranchNameWithoutRemote } from './git/models/branch';
import { isCommit } from './git/models/commit';
import { Logger, LogLevel } from './logger';
import { showDebugLoggingWarningMessage, showInsidersErrorMessage, showWhatsNewMessage } from './messages';
import {
showDebugLoggingWarningMessage,
showInsidersErrorMessage,
showInsidersExpiredErrorMessage,
showWhatsNewMessage,
} from './messages';
import { registerPartnerActionRunners } from './partners';
import { StorageKeys, SyncedStorageKeys } from './storage';
import { executeCommand, executeCoreCommand, registerCommands } from './system/command';
import { setDefaultDateLocales } from './system/date';
import { once } from './system/event';
import { Stopwatch } from './system/stopwatch';
import { compare, satisfies } from './system/version';
import { compare, fromString, satisfies } from './system/version';
import { isViewNode } from './views/nodes/viewNode';
export async function activate(context: ExtensionContext): Promise<GitLensApi | undefined> {
@ -63,6 +68,23 @@ export async function activate(context: ExtensionContext): Promise
}
}
// Ensure that this insiders version hasn't expired
if (insiders) {
const v = fromString(gitlensVersion);
// Get the build date from the version number
const date = new Date(v.major, v.minor - 1, Number(v.patch.toString().substring(0, 2)));
// If the build date is older than 14 days then show the expired error message
if (date.getTime() < Date.now() - 14 * 24 * 60 * 60 * 1000) {
sw.stop({ message: ` was NOT activated because the insiders version (${gitlensVersion}) has expired` });
// If we don't use a setTimeout here this notification will get lost for some reason
setTimeout(() => void showInsidersExpiredErrorMessage(gitlensVersion), 0);
return undefined;
}
}
if (!workspace.isTrusted) {
void setContext(ContextKeys.Untrusted, true);
context.subscriptions.push(

+ 7
- 1
src/messages.ts Zobrazit soubor

@ -108,7 +108,13 @@ export function showInsidersErrorMessage() {
return showMessage(
'error',
'GitLens (Insiders) cannot be used while GitLens is also enabled. Please ensure that only one version is enabled.',
SuppressedMessages.GitDisabledWarning,
);
}
export function showInsidersExpiredErrorMessage(version: string) {
return showMessage(
'error',
`GitLens (Insiders) version (${version}) has expired. Please install a more recent version.`,
);
}

Načítá se…
Zrušit
Uložit