Skip to content

Commit

Permalink
fix(versioning/loose): sort numeric parts numerically (#26341)
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh committed Dec 17, 2023
1 parent 24f8f0d commit d74fa61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/modules/versioning/loose/index.spec.ts
Expand Up @@ -53,6 +53,7 @@ describe('modules/versioning/loose/index', () => {
a | b | expected
${'2.4.0'} | ${'2.4'} | ${true}
${'2.4.2'} | ${'2.4.1'} | ${true}
${'2.4.100'} | ${'2.4.99'} | ${true}
${'2.4.beta'} | ${'2.4.alpha'} | ${true}
${'1.9'} | ${'2'} | ${false}
${'1.9'} | ${'1.9.1'} | ${false}
Expand All @@ -63,6 +64,7 @@ describe('modules/versioning/loose/index', () => {
${'2024-07-21T11-33-05.abc123'} | ${'2023-06-21T11-33-05.abc123'} | ${true}
${'2023-07-21T11-33-05.abc123'} | ${'2023-07-21T11-33-04.abc123'} | ${true}
${'2023-07-21-113305-abc123'} | ${'2023-07-21-113304-abc123'} | ${true}
${'1.1.5-100'} | ${'1.1.5-99'} | ${true}
`('isGreaterThan("$a", "$b") === $expected', ({ a, b, expected }) => {
expect(loose.isGreaterThan(a, b)).toBe(expected);
});
Expand Down
4 changes: 3 additions & 1 deletion lib/modules/versioning/loose/index.ts
Expand Up @@ -52,7 +52,9 @@ class LooseVersioningApi extends GenericVersioningApi {
}

if (parsed1.suffix && parsed2.suffix) {
return parsed1.suffix.localeCompare(parsed2.suffix);
return parsed1.suffix.localeCompare(parsed2.suffix, undefined, {
numeric: true,
});
}

if (parsed1.suffix) {
Expand Down

0 comments on commit d74fa61

Please sign in to comment.