From 71b697dd8b66782914ce9f72d5184b81e04f3cf6 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Tue, 19 May 2026 13:16:56 +0100 Subject: [PATCH] Add helpers for GHES versions --- pr-checks/update-ghes-versions.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pr-checks/update-ghes-versions.ts b/pr-checks/update-ghes-versions.ts index 52b3367a2..8d171cfdc 100644 --- a/pr-checks/update-ghes-versions.ts +++ b/pr-checks/update-ghes-versions.ts @@ -24,6 +24,26 @@ export enum EnvVar { ENTERPRISE_RELEASES_PATH = "ENTERPRISE_RELEASES_PATH", } +/** + * The semver specification requires three numeric components, but GHES release families + * only have two. This function uses `semver.coerce` to first coerce the version string + * into an acceptable input for `semver.parse`. E.g. `3.10` becomes `3.10.0`. + */ +export function parseEnterpriseVersion(val: string): SemVer | null { + return semver.parse(semver.coerce(val)); +} + +/** + * Mirroring `parseEnterpriseVersion`, this function returns only the major and minor + * version components from `ver`. + */ +export function printEnterpriseVersion(ver: SemVer) { + if (ver.patch === 0) { + return `${ver.major}.${ver.minor}`; + } + return ver.toString(); +} + /** The JSON schema for `API_COMPATIBILITY_FILE`. */ const apiCompatibilitySchema = { minimumVersion: json.string,