Skip to content

Commit fbaab9b

Browse files
committed
check minimum patch version when selecting tagged release
1 parent 5f14ccb commit fbaab9b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/select-zls-version.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,17 @@ async function selectOnTaggedRelease(
188188
.first<{ JsonData: string }>();
189189

190190
if (selectedRelease !== null) {
191-
return JSON.parse(selectedRelease.JsonData) as D2JsonData;
191+
const jsonData = JSON.parse(selectedRelease.JsonData) as D2JsonData;
192+
const minRuntimeZigVersion = SemanticVersion.parse(
193+
jsonData.minimumRuntimeZigVersion,
194+
);
195+
assert(minRuntimeZigVersion !== null);
196+
197+
if (SemanticVersion.satisfies(zigVersion, minRuntimeZigVersion, true)) {
198+
return jsonData;
199+
} else {
200+
return SelectVersionFailureCode.TaggedReleaseIncompatible;
201+
}
192202
}
193203

194204
// If the version is older than the oldest available tagged release then the version is declared unsupported.

test/select-zls-version.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,16 @@ describe("/v1/zls/select-version", () => {
465465
},
466466
]);
467467

468+
{
469+
const response = await selectZLSVersion(
470+
"0.15.0",
471+
VersionCompatibility.Full,
472+
);
473+
expect(response.code).toBe(
474+
SelectVersionFailureCode.TaggedReleaseIncompatible,
475+
);
476+
}
477+
468478
{
469479
const response = await selectZLSVersion(
470480
"0.15.1-dev.1+aaaaaaaaa",

0 commit comments

Comments
 (0)