Browse Source

Adds expiration to insiders builds

main
Eric Amodio 2 years ago
parent
commit
3b42557e6d
2 changed files with 31 additions and 3 deletions
  1. +24
    -2
      src/extension.ts
  2. +7
    -1
      src/messages.ts

+ 24
- 2
src/extension.ts View File

@ -12,14 +12,19 @@ import { isGitUri } from './git/gitUri';
import { getBranchNameWithoutRemote } from './git/models/branch'; import { getBranchNameWithoutRemote } from './git/models/branch';
import { isCommit } from './git/models/commit'; import { isCommit } from './git/models/commit';
import { Logger, LogLevel } from './logger'; import { Logger, LogLevel } from './logger';
import { showDebugLoggingWarningMessage, showInsidersErrorMessage, showWhatsNewMessage } from './messages';
import {
showDebugLoggingWarningMessage,
showInsidersErrorMessage,
showInsidersExpiredErrorMessage,
showWhatsNewMessage,
} from './messages';
import { registerPartnerActionRunners } from './partners'; import { registerPartnerActionRunners } from './partners';
import { StorageKeys, SyncedStorageKeys } from './storage'; import { StorageKeys, SyncedStorageKeys } from './storage';
import { executeCommand, executeCoreCommand, registerCommands } from './system/command'; import { executeCommand, executeCoreCommand, registerCommands } from './system/command';
import { setDefaultDateLocales } from './system/date'; import { setDefaultDateLocales } from './system/date';
import { once } from './system/event'; import { once } from './system/event';
import { Stopwatch } from './system/stopwatch'; import { Stopwatch } from './system/stopwatch';
import { compare, satisfies } from './system/version';
import { compare, fromString, satisfies } from './system/version';
import { isViewNode } from './views/nodes/viewNode'; import { isViewNode } from './views/nodes/viewNode';
export async function activate(context: ExtensionContext): Promise<GitLensApi | undefined> { 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) { if (!workspace.isTrusted) {
void setContext(ContextKeys.Untrusted, true); void setContext(ContextKeys.Untrusted, true);
context.subscriptions.push( context.subscriptions.push(

+ 7
- 1
src/messages.ts View File

@ -108,7 +108,13 @@ export function showInsidersErrorMessage() {
return showMessage( return showMessage(
'error', 'error',
'GitLens (Insiders) cannot be used while GitLens is also enabled. Please ensure that only one version is enabled.', '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.`,
); );
} }

Loading…
Cancel
Save