Skip to content

Commit

Permalink
fix: Support more semver formats in cargo.toDebianVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzypixelz committed Jun 18, 2024
1 parent efce0cd commit 0df7a31
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 137 deletions.
17 changes: 2 additions & 15 deletions dist/build-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__();
Expand Down
17 changes: 2 additions & 15 deletions dist/build-crates-standalone-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__();
Expand Down
17 changes: 2 additions & 15 deletions dist/bump-crates-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__();
Expand Down
17 changes: 2 additions & 15 deletions dist/publish-crates-cargo-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__();
Expand Down
17 changes: 2 additions & 15 deletions dist/publish-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__();
Expand Down
17 changes: 2 additions & 15 deletions dist/publish-crates-eclipse-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__();
Expand Down
17 changes: 2 additions & 15 deletions dist/publish-crates-github-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__();
Expand Down
17 changes: 2 additions & 15 deletions dist/publish-crates-homebrew-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__();
Expand Down
19 changes: 2 additions & 17 deletions src/cargo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}

0 comments on commit 0df7a31

Please sign in to comment.