File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ import {
1111 filterForVersion ,
1212 addToGitignore ,
1313 replaceGitignore ,
14- removeDirectory
14+ removeDirectory ,
15+ isVersionString
1516} from './util.js' ;
1617import applyNodeChanges from './applyNodeChanges.js' ;
1718import { chromiumGit , v8Deps } from './constants.js' ;
@@ -38,14 +39,13 @@ export default function majorUpdate() {
3839 } ;
3940} ;
4041
41- const versionReg = / ^ \d + ( \. \d + ) + $ / ;
4242function 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 ) {
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { execa } from 'execa';
66import { Listr } from 'listr2' ;
77
88import { getCurrentV8Version } from './common.js' ;
9+ import { isVersionString } from './util.js' ;
910
1011export 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}
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments