neiam
/action-setup-beam
action-setup-beam
public · Issues · Pulls · Labels · Forks · Compare · Actions queued
⭐
Log in to mark this repository.
Match only on what we know should match (versions start with numbers, after OTP-) (#341)
afe5922 · Paulo F. Oliveira · 2025-05-30 04:43
Files changed
modified
dist/index.js
+8
−4
@@ -26067,9 +26067,13 @@ function requestedVersionFor(tool, version, originListing, mirrors) {
| 26067 | 26067 | ) |
| 26068 | 26068 | } |
| 26069 | 26069 | |
| 26070 | +const knownBranches = ['main', 'master', 'maint'] | |
| 26071 | +const nonSpecificVersions = ['nightly', 'latest'] | |
| 26072 | + | |
| 26070 | 26073 | async function getElixirVersion(exSpec0, otpVersion0) { |
| 26071 | 26074 | 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] | |
| 26073 | 26077 | |
| 26074 | 26078 | const otpSuffix = /-otp-(\d+)/ |
| 26075 | 26079 | const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null |
@@ -26316,7 +26320,9 @@ function gt(left, right) {
| 26316 | 26320 | |
| 26317 | 26321 | function validVersion(v) { |
| 26318 | 26322 | return ( |
| 26319 | − v.match(/main|master|nightly|latest/g) == null && | |
| 26323 | + v.match( | |
| 26324 | + new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`), | |
| 26325 | + ) == null && | |
| 26320 | 26326 | !v.startsWith('a') && |
| 26321 | 26327 | !v.startsWith('b') |
| 26322 | 26328 | ) |
@@ -26435,8 +26441,6 @@ function isRC(ver) {
| 26435 | 26441 | return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)')) |
| 26436 | 26442 | } |
| 26437 | 26443 | |
| 26438 | −const knownBranches = ['main', 'master', 'maint'] | |
| 26439 | − | |
| 26440 | 26444 | function isKnownBranch(ver) { |
| 26441 | 26445 | return knownBranches.includes(ver) |
| 26442 | 26446 | } |
modified
src/setup-beam.js
+8
−4
@@ -192,9 +192,13 @@ function requestedVersionFor(tool, version, originListing, mirrors) {
| 192 | 192 | ) |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | +const knownBranches = ['main', 'master', 'maint'] | |
| 196 | +const nonSpecificVersions = ['nightly', 'latest'] | |
| 197 | + | |
| 195 | 198 | async function getElixirVersion(exSpec0, otpVersion0) { |
| 196 | 199 | 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] | |
| 198 | 202 | |
| 199 | 203 | const otpSuffix = /-otp-(\d+)/ |
| 200 | 204 | const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null |
@@ -441,7 +445,9 @@ function gt(left, right) {
| 441 | 445 | |
| 442 | 446 | function validVersion(v) { |
| 443 | 447 | return ( |
| 444 | − v.match(/main|master|nightly|latest/g) == null && | |
| 448 | + v.match( | |
| 449 | + new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`), | |
| 450 | + ) == null && | |
| 445 | 451 | !v.startsWith('a') && |
| 446 | 452 | !v.startsWith('b') |
| 447 | 453 | ) |
@@ -560,8 +566,6 @@ function isRC(ver) {
| 560 | 566 | return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)')) |
| 561 | 567 | } |
| 562 | 568 | |
| 563 | −const knownBranches = ['main', 'master', 'maint'] | |
| 564 | − | |
| 565 | 569 | function isKnownBranch(ver) { |
| 566 | 570 | return knownBranches.includes(ver) |
| 567 | 571 | } |
Parents: db4b4ce