From 09630654fd6564218631714a4e600bc7b8a12399 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Wed, 28 Feb 2024 17:45:37 +0100 Subject: [PATCH] Revert "fix: version test for equal pre-release versions" This reverts commit 2613b71a75c7d25ed7257190a1601322f480eac5. --- src/utils/__tests__/version.test.ts | 19 ------------------- src/utils/version.ts | 7 +++---- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/utils/__tests__/version.test.ts b/src/utils/__tests__/version.test.ts index 76020deb..c3922d84 100644 --- a/src/utils/__tests__/version.test.ts +++ b/src/utils/__tests__/version.test.ts @@ -195,25 +195,6 @@ describe('versionGreaterOrEqualThan', () => { expect(() => versionGreaterOrEqualThan(v1, v2)).toThrowError(); expect(() => versionGreaterOrEqualThan(v2, v1)).toThrowError(); }); - - test('can compare pre parts that are the same', () => { - let v1 = parseVersion('1.2.3-dev.0')!; - let v2 = parseVersion('1.2.3-dev.0')!; - expect(versionGreaterOrEqualThan(v1, v2)).toBe(true); - expect(versionGreaterOrEqualThan(v2, v1)).toBe(true); - - v1 = parseVersion('1.2.3-dev.0+A')!; - v2 = parseVersion('1.2.3-dev.0+A')!; - expect(versionGreaterOrEqualThan(v1, v2)).toBe(true); - expect(versionGreaterOrEqualThan(v2, v1)).toBe(true); - }); - - test('can compare pre parts that are the same but have different builds', () => { - const v1 = parseVersion('1.2.3-dev.0+buildA')!; - const v2 = parseVersion('1.2.3-dev.0+buildB')!; - expect(versionGreaterOrEqualThan(v1, v2)).toBe(false); - expect(versionGreaterOrEqualThan(v2, v1)).toBe(false); - }); }); describe('getPackage', () => { diff --git a/src/utils/version.ts b/src/utils/version.ts index 853e5d8b..5ab3581a 100644 --- a/src/utils/version.ts +++ b/src/utils/version.ts @@ -89,8 +89,6 @@ export function versionGreaterOrEqualThan(v1: SemVer, v2: SemVer): boolean { return true; } else if (v1.pre && !v2.pre) { return false; - } else if (v1.pre && v2.pre && v1.pre === v2.pre) { - return v1.build === v2.build; } else if (v1.pre && v2.pre && v1.pre !== v2.pre && /^\d+$/.test(v1.pre) && /^\d+$/.test(v2.pre)) { return v1.pre > v2.pre; } else if (v1.build || v2.build || v1.pre || v2.pre) { @@ -159,6 +157,7 @@ export function getPackageVersion(): string { * Returns the stringified version of the passed SemVer object. */ export function semVerToString(s: SemVer) { - return `${s.major}.${s.minor}.${s.patch}${s.pre ? `-${s.pre}` : ''}${s.build ? `+${s.build}` : '' - }`; + return `${s.major}.${s.minor}.${s.patch}${s.pre ? `-${s.pre}` : ''}${ + s.build ? `+${s.build}` : '' + }`; }