Skip to content

Commit afe5922

Browse files
Match only on what we know should match (versions start with numbers, after OTP-) (#341)
1 parent db4b4ce commit afe5922

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

dist/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26067,9 +26067,13 @@ function requestedVersionFor(tool, version, originListing, mirrors) {
2606726067
)
2606826068
}
2606926069

26070+
const knownBranches = ['main', 'master', 'maint']
26071+
const nonSpecificVersions = ['nightly', 'latest']
26072+
2607026073
async function getElixirVersion(exSpec0, otpVersion0) {
2607126074
const otpVersion = otpVersion0.match(/^(?:OTP-)?(.+)$/)[1]
26072-
let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1]
26075+
const regex = `^(\\d{1,3}|${knownBranches.join('|')}|${nonSpecificVersions.join('|')})?.*$`
26076+
let otpVersionMajor = otpVersion.match(new RegExp(regex))[1]
2607326077

2607426078
const otpSuffix = /-otp-(\d+)/
2607526079
const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null
@@ -26316,7 +26320,9 @@ function gt(left, right) {
2631626320

2631726321
function validVersion(v) {
2631826322
return (
26319-
v.match(/main|master|nightly|latest/g) == null &&
26323+
v.match(
26324+
new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`),
26325+
) == null &&
2632026326
!v.startsWith('a') &&
2632126327
!v.startsWith('b')
2632226328
)
@@ -26435,8 +26441,6 @@ function isRC(ver) {
2643526441
return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)'))
2643626442
}
2643726443

26438-
const knownBranches = ['main', 'master', 'maint']
26439-
2644026444
function isKnownBranch(ver) {
2644126445
return knownBranches.includes(ver)
2644226446
}

src/setup-beam.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,13 @@ function requestedVersionFor(tool, version, originListing, mirrors) {
192192
)
193193
}
194194

195+
const knownBranches = ['main', 'master', 'maint']
196+
const nonSpecificVersions = ['nightly', 'latest']
197+
195198
async function getElixirVersion(exSpec0, otpVersion0) {
196199
const otpVersion = otpVersion0.match(/^(?:OTP-)?(.+)$/)[1]
197-
let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1]
200+
const regex = `^(\\d{1,3}|${knownBranches.join('|')}|${nonSpecificVersions.join('|')})?.*$`
201+
let otpVersionMajor = otpVersion.match(new RegExp(regex))[1]
198202

199203
const otpSuffix = /-otp-(\d+)/
200204
const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null
@@ -441,7 +445,9 @@ function gt(left, right) {
441445

442446
function validVersion(v) {
443447
return (
444-
v.match(/main|master|nightly|latest/g) == null &&
448+
v.match(
449+
new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`),
450+
) == null &&
445451
!v.startsWith('a') &&
446452
!v.startsWith('b')
447453
)
@@ -560,8 +566,6 @@ function isRC(ver) {
560566
return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)'))
561567
}
562568

563-
const knownBranches = ['main', 'master', 'maint']
564-
565569
function isKnownBranch(ver) {
566570
return knownBranches.includes(ver)
567571
}

0 commit comments

Comments
 (0)