Override OTP version when specified in Elixir spec (#330)

This commit is contained in:
Kevin Schweikert
2025-05-25 17:49:21 +02:00
committed by GitHub
parent 98ad08a06d
commit 3e793a73ab
3 changed files with 20 additions and 2 deletions
+7 -1
View File
@@ -9284,7 +9284,13 @@ async function getOTPVersion(otpSpec0, osVersion) {
async function getElixirVersion(exSpec0, otpVersion0) { async function getElixirVersion(exSpec0, otpVersion0) {
const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2] const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2]
const otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1]
const userSuppliedOtp = exSpec0.match(/-otp-(\d+)/)?.[1] ?? null
if (userSuppliedOtp && isVersion(userSuppliedOtp)) {
otpVersionMajor = userSuppliedOtp
}
const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions() const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions()
const spec = exSpec0.replace(/-otp-.*$/, '') const spec = exSpec0.replace(/-otp-.*$/, '')
+7 -1
View File
@@ -184,7 +184,13 @@ async function getOTPVersion(otpSpec0, osVersion) {
async function getElixirVersion(exSpec0, otpVersion0) { async function getElixirVersion(exSpec0, otpVersion0) {
const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2] const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2]
const otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1]
const userSuppliedOtp = exSpec0.match(/-otp-(\d+)/)?.[1] ?? null
if (userSuppliedOtp && isVersion(userSuppliedOtp)) {
otpVersionMajor = userSuppliedOtp
}
const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions() const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions()
const spec = exSpec0.replace(/-otp-.*$/, '') const spec = exSpec0.replace(/-otp-.*$/, '')
+6
View File
@@ -511,6 +511,12 @@ describe('.getOTPVersion(_) - Elixir', () => {
got = await setupBeam.getElixirVersion(spec, otpVersion) got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected) assert.deepStrictEqual(got, expected)
spec = '1.16.2-otp-26'
otpVersion = 'OTP-27'
expected = 'v1.16.2-otp-26'
got = await setupBeam.getElixirVersion(spec, otpVersion)
assert.deepStrictEqual(got, expected)
spec = '1.12.1' spec = '1.12.1'
otpVersion = 'OTP-24.0.2' otpVersion = 'OTP-24.0.2'
expected = 'v1.12.1-otp-24' expected = 'v1.12.1-otp-24'