Преглед изворни кода

Adds pre support to versions

Changes migration to be from beta2
main
Eric Amodio пре 6 година
родитељ
комит
7b7bde819c
2 измењених фајлова са 13 додато и 5 уклоњено
  1. +1
    -1
      src/extension.ts
  2. +12
    -4
      src/system/version.ts

+ 1
- 1
src/extension.ts Прегледај датотеку

@ -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 Прегледај датотеку

@ -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);
}
}

Loading…
Откажи
Сачувај