Przeglądaj źródła

Adds pre support to versions

Changes migration to be from beta2
main
Eric Amodio 6 lat temu
rodzic
commit
7b7bde819c
2 zmienionych plików z 13 dodań i 5 usunięć
  1. +1
    -1
      src/extension.ts
  2. +12
    -4
      src/system/version.ts

+ 1
- 1
src/extension.ts Wyświetl plik

@ -133,7 +133,7 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin
}
}
if (Versions.compare(previous, Versions.from(7, 3, 0)) !== 1) {
if (Versions.compare(previous, Versions.from(7, 3, 0, 'beta2')) !== 1) {
const oldSection = 'advanced.maxQuickHistory';
const inspection = configuration.inspect(oldSection);
if (inspection !== undefined) {

+ 12
- 4
src/system/version.ts Wyświetl plik

@ -5,6 +5,7 @@ export namespace Versions {
major: number;
minor: number;
patch: number;
pre?: string;
}
export function compare(v1: Version, v2: Version): number {
@ -17,19 +18,26 @@ export namespace Versions {
if (v1.patch > v2.patch) return 1;
if (v1.patch < v2.patch) return -1;
if (v1.pre === undefined && v2.pre !== undefined) return 1;
if (v1.pre !== undefined && v2.pre === undefined) return -1;
if (v1.pre !== undefined && v2.pre !== undefined) return v1.pre.localeCompare(v2.pre);
return 0;
}
export function from(major: string | number, minor: string | number, patch: string | number): Version {
export function from(major: string | number, minor: string | number, patch: string | number, pre?: string): Version {
return {
major: typeof major === 'string' ? parseInt(major, 10) : major,
minor: typeof minor === 'string' ? parseInt(minor, 10) : minor,
patch: typeof patch === 'string' ? parseInt(patch, 10) : patch
patch: typeof patch === 'string' ? parseInt(patch, 10) : patch,
pre: pre
};
}
export function fromString(version: string): Version {
const [major, minor, patch] = version.split('.');
return from(major, minor, patch);
const [ver, pre] = version.split('-');
const [major, minor, patch] = ver.split('.');
return from(major, minor, patch, pre);
}
}

Ładowanie…
Anuluj
Zapisz