Skip to content

Commit cf03df4

Browse files
authored
fix: use correct V8 tag for minor updates (#695)
Refs: #675
1 parent 0d01f9a commit cf03df4

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

lib/update-v8/majorUpdate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
filterForVersion,
1212
addToGitignore,
1313
replaceGitignore,
14-
removeDirectory
14+
removeDirectory,
15+
isVersionString
1516
} from './util.js';
1617
import applyNodeChanges from './applyNodeChanges.js';
1718
import { chromiumGit, v8Deps } from './constants.js';
@@ -38,14 +39,13 @@ export default function majorUpdate() {
3839
};
3940
};
4041

41-
const versionReg = /^\d+(\.\d+)+$/;
4242
function checkoutBranch() {
4343
return {
4444
title: 'Checkout V8 branch',
4545
task: async(ctx) => {
4646
let version = ctx.branch;
4747
await ctx.execGitV8('checkout', 'origin/main');
48-
if (!versionReg.test(version)) {
48+
if (!isVersionString(version)) {
4949
// try to get the latest tag
5050
const res = await ctx.execGitV8(
5151
'tag',
@@ -54,7 +54,7 @@ function checkoutBranch() {
5454
'--sort',
5555
'version:refname'
5656
);
57-
const tags = res.stdout.split('\n').filter(tag => versionReg.test(tag));
57+
const tags = res.stdout.split('\n').filter(isVersionString);
5858
const lastTag = tags[tags.length - 1];
5959
if (lastTag) version = lastTag;
6060
if (version.split('.').length === 3) {

lib/update-v8/minorUpdate.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { execa } from 'execa';
66
import { Listr } from 'listr2';
77

88
import { getCurrentV8Version } from './common.js';
9+
import { isVersionString } from './util.js';
910

1011
export default function minorUpdate() {
1112
return {
@@ -34,7 +35,7 @@ function getLatestV8Version() {
3435
cwd: ctx.v8Dir,
3536
encoding: 'utf8'
3637
});
37-
const tags = toSortedArray(result.stdout);
38+
const tags = filterAndSortTags(result.stdout);
3839
ctx.latestVersion = tags[0];
3940
}
4041
};
@@ -79,10 +80,10 @@ async function applyPatch(ctx, latestStr) {
7980
}
8081
}
8182

82-
function toSortedArray(tags) {
83+
function filterAndSortTags(tags) {
8384
return tags
8485
.split(/[\r\n]+/)
85-
.filter((tag) => tag !== '')
86+
.filter(isVersionString)
8687
.map((tag) => tag.split('.'))
8788
.sort(sortVersions);
8889
}

lib/update-v8/util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ export function removeDirectory(path) {
5656
return fs.rmdir(path, { recursive: true });
5757
}
5858
}
59+
60+
export function isVersionString(str) {
61+
return /^\d+(\.\d+)+$/.test(str);
62+
}

0 commit comments

Comments
 (0)