From 0df7a3124bf6fa7438d6a0587c54eaaf1432af16 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Tue, 18 Jun 2024 14:08:31 +0200 Subject: [PATCH] fix: Support more semver formats in `cargo.toDebianVersion` --- dist/build-crates-debian-main.js | 17 ++--------------- dist/build-crates-standalone-main.js | 17 ++--------------- dist/bump-crates-main.js | 17 ++--------------- dist/publish-crates-cargo-main.js | 17 ++--------------- dist/publish-crates-debian-main.js | 17 ++--------------- dist/publish-crates-eclipse-main.js | 17 ++--------------- dist/publish-crates-github-main.js | 17 ++--------------- dist/publish-crates-homebrew-main.js | 17 ++--------------- src/cargo.ts | 19 ++----------------- 9 files changed, 18 insertions(+), 137 deletions(-) diff --git a/dist/build-crates-debian-main.js b/dist/build-crates-debian-main.js index d5d652c..014f2a2 100644 --- a/dist/build-crates-debian-main.js +++ b/dist/build-crates-debian-main.js @@ -127534,21 +127534,8 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - revision = revision ?? 1; - const re = /^(\d+\.\d+\.\d+)(?:-((?:alpha|beta|rc)\.\d+))?$/g; - const matches = Array.from(version.matchAll(re)); - if (matches.length === 0) { - throw Error(`Unsupported version format: ${version}`); - } - const [base, suffix] = matches[0].slice(1); - if (suffix === undefined) { - // In this case the version is of the form X.Y.Z - return `${base}-${revision}`; - } - else { - // In this case the version is of the form X.Y.Z-(alpha|beta|rc).N - return `${base}~${suffix}-${revision}`; - } + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + return `${version.replace("-", "~")}-${revision ?? 1}`; } __webpack_async_result__(); diff --git a/dist/build-crates-standalone-main.js b/dist/build-crates-standalone-main.js index d108476..c3b836f 100644 --- a/dist/build-crates-standalone-main.js +++ b/dist/build-crates-standalone-main.js @@ -127518,21 +127518,8 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - revision = revision ?? 1; - const re = /^(\d+\.\d+\.\d+)(?:-((?:alpha|beta|rc)\.\d+))?$/g; - const matches = Array.from(version.matchAll(re)); - if (matches.length === 0) { - throw Error(`Unsupported version format: ${version}`); - } - const [base, suffix] = matches[0].slice(1); - if (suffix === undefined) { - // In this case the version is of the form X.Y.Z - return `${base}-${revision}`; - } - else { - // In this case the version is of the form X.Y.Z-(alpha|beta|rc).N - return `${base}~${suffix}-${revision}`; - } + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + return `${version.replace("-", "~")}-${revision ?? 1}`; } __webpack_async_result__(); diff --git a/dist/bump-crates-main.js b/dist/bump-crates-main.js index d0b2946..da9a2cd 100644 --- a/dist/bump-crates-main.js +++ b/dist/bump-crates-main.js @@ -81240,21 +81240,8 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - revision = revision ?? 1; - const re = /^(\d+\.\d+\.\d+)(?:-((?:alpha|beta|rc)\.\d+))?$/g; - const matches = Array.from(version.matchAll(re)); - if (matches.length === 0) { - throw Error(`Unsupported version format: ${version}`); - } - const [base, suffix] = matches[0].slice(1); - if (suffix === undefined) { - // In this case the version is of the form X.Y.Z - return `${base}-${revision}`; - } - else { - // In this case the version is of the form X.Y.Z-(alpha|beta|rc).N - return `${base}~${suffix}-${revision}`; - } + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + return `${version.replace("-", "~")}-${revision ?? 1}`; } __webpack_async_result__(); diff --git a/dist/publish-crates-cargo-main.js b/dist/publish-crates-cargo-main.js index c81a04c..65e1c57 100644 --- a/dist/publish-crates-cargo-main.js +++ b/dist/publish-crates-cargo-main.js @@ -81127,21 +81127,8 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - revision = revision ?? 1; - const re = /^(\d+\.\d+\.\d+)(?:-((?:alpha|beta|rc)\.\d+))?$/g; - const matches = Array.from(version.matchAll(re)); - if (matches.length === 0) { - throw Error(`Unsupported version format: ${version}`); - } - const [base, suffix] = matches[0].slice(1); - if (suffix === undefined) { - // In this case the version is of the form X.Y.Z - return `${base}-${revision}`; - } - else { - // In this case the version is of the form X.Y.Z-(alpha|beta|rc).N - return `${base}~${suffix}-${revision}`; - } + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + return `${version.replace("-", "~")}-${revision ?? 1}`; } __webpack_async_result__(); diff --git a/dist/publish-crates-debian-main.js b/dist/publish-crates-debian-main.js index a577809..2ec3ad7 100644 --- a/dist/publish-crates-debian-main.js +++ b/dist/publish-crates-debian-main.js @@ -127513,21 +127513,8 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - revision = revision ?? 1; - const re = /^(\d+\.\d+\.\d+)(?:-((?:alpha|beta|rc)\.\d+))?$/g; - const matches = Array.from(version.matchAll(re)); - if (matches.length === 0) { - throw Error(`Unsupported version format: ${version}`); - } - const [base, suffix] = matches[0].slice(1); - if (suffix === undefined) { - // In this case the version is of the form X.Y.Z - return `${base}-${revision}`; - } - else { - // In this case the version is of the form X.Y.Z-(alpha|beta|rc).N - return `${base}~${suffix}-${revision}`; - } + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + return `${version.replace("-", "~")}-${revision ?? 1}`; } __webpack_async_result__(); diff --git a/dist/publish-crates-eclipse-main.js b/dist/publish-crates-eclipse-main.js index f212343..e6ac9de 100644 --- a/dist/publish-crates-eclipse-main.js +++ b/dist/publish-crates-eclipse-main.js @@ -127594,21 +127594,8 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - revision = revision ?? 1; - const re = /^(\d+\.\d+\.\d+)(?:-((?:alpha|beta|rc)\.\d+))?$/g; - const matches = Array.from(version.matchAll(re)); - if (matches.length === 0) { - throw Error(`Unsupported version format: ${version}`); - } - const [base, suffix] = matches[0].slice(1); - if (suffix === undefined) { - // In this case the version is of the form X.Y.Z - return `${base}-${revision}`; - } - else { - // In this case the version is of the form X.Y.Z-(alpha|beta|rc).N - return `${base}~${suffix}-${revision}`; - } + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + return `${version.replace("-", "~")}-${revision ?? 1}`; } __webpack_async_result__(); diff --git a/dist/publish-crates-github-main.js b/dist/publish-crates-github-main.js index 6903988..6395a4c 100644 --- a/dist/publish-crates-github-main.js +++ b/dist/publish-crates-github-main.js @@ -127594,21 +127594,8 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - revision = revision ?? 1; - const re = /^(\d+\.\d+\.\d+)(?:-((?:alpha|beta|rc)\.\d+))?$/g; - const matches = Array.from(version.matchAll(re)); - if (matches.length === 0) { - throw Error(`Unsupported version format: ${version}`); - } - const [base, suffix] = matches[0].slice(1); - if (suffix === undefined) { - // In this case the version is of the form X.Y.Z - return `${base}-${revision}`; - } - else { - // In this case the version is of the form X.Y.Z-(alpha|beta|rc).N - return `${base}~${suffix}-${revision}`; - } + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + return `${version.replace("-", "~")}-${revision ?? 1}`; } __webpack_async_result__(); diff --git a/dist/publish-crates-homebrew-main.js b/dist/publish-crates-homebrew-main.js index 3ba95e2..711dc5c 100644 --- a/dist/publish-crates-homebrew-main.js +++ b/dist/publish-crates-homebrew-main.js @@ -127498,21 +127498,8 @@ function buildDebian(path, target, version) { * @returns Modified version. */ function toDebianVersion(version, revision) { - revision = revision ?? 1; - const re = /^(\d+\.\d+\.\d+)(?:-((?:alpha|beta|rc)\.\d+))?$/g; - const matches = Array.from(version.matchAll(re)); - if (matches.length === 0) { - throw Error(`Unsupported version format: ${version}`); - } - const [base, suffix] = matches[0].slice(1); - if (suffix === undefined) { - // In this case the version is of the form X.Y.Z - return `${base}-${revision}`; - } - else { - // In this case the version is of the form X.Y.Z-(alpha|beta|rc).N - return `${base}~${suffix}-${revision}`; - } + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + return `${version.replace("-", "~")}-${revision ?? 1}`; } __webpack_async_result__(); diff --git a/src/cargo.ts b/src/cargo.ts index 7b7594e..1a083f6 100644 --- a/src/cargo.ts +++ b/src/cargo.ts @@ -364,21 +364,6 @@ export function buildDebian(path: string, target: string, version: string) { * @returns Modified version. */ export function toDebianVersion(version: string, revision?: number): string { - revision = revision ?? 1; - - const re = /^(\d+\.\d+\.\d+)(?:-((?:alpha|beta|rc)\.\d+))?$/g; - const matches = Array.from(version.matchAll(re)); - - if (matches.length === 0) { - throw Error(`Unsupported version format: ${version}`); - } - const [base, suffix] = matches[0].slice(1); - - if (suffix === undefined) { - // In this case the version is of the form X.Y.Z - return `${base}-${revision}`; - } else { - // In this case the version is of the form X.Y.Z-(alpha|beta|rc).N - return `${base}~${suffix}-${revision}`; - } + // HACK(fuzzypixelz): This is an oversimplification of the Debian Policy + return `${version.replace("-", "~")}-${revision ?? 1}`; }