Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update cargo.toDebianVersion to handle cmake #234

Merged
merged 5 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion __tests__/cargo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,21 @@ describe("cargo", () => {
const tmp = await downloadGitHubRepo("eclipse-zenoh/zenoh", SHA_ZENOH);

const version = "1.2.3-beta.1";
const debian_version = "1.2.3~beta.1-1";
await cargo.bumpDependencies(tmp, /zenoh.*/, version);

expect(toml.get(`${tmp}/Cargo.toml`, ["workspace", "dependencies", "zenoh", "version"])).toEqual(version);
expect(toml.get(`${tmp}/zenoh/Cargo.toml`, ["package", "metadata", "deb", "depends"])).toEqual(
`zenohd (=${version}), zenoh-plugin-rest (=${version}), zenoh-plugin-storage-manager (=${version})`,
`zenohd (=${debian_version}), zenoh-plugin-rest (=${debian_version}), zenoh-plugin-storage-manager (=${debian_version})`,
);
});

test("toDebianVersion()", async () => {
expect(cargo.toDebianVersion("1.0.0.0")).toEqual("1.0.0~dev-1");
expect(cargo.toDebianVersion("1.0.0.11")).toEqual("1.0.0~11-1");
expect(cargo.toDebianVersion("1.0.0-rc.1")).toEqual("1.0.0~rc.1-1");
expect(cargo.toDebianVersion("1.0.0")).toEqual("1.0.0");
expect(cargo.toDebianVersion("1.0.0.1")).toEqual("1.0.0~1-1");
expect(cargo.toDebianVersion("1.0.0.1", 2)).toEqual("1.0.0~1-2");
});
});
22 changes: 20 additions & 2 deletions dist/build-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127537,8 +127537,26 @@ function buildDebian(path, target, version) {
* @returns Modified version.
*/
function toDebianVersion(version, revision) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
return `${version.replace("-", "~")}-${revision ?? 1}`;
let deb_version = version;
// Check if version is semver or cmake version
if (version.includes("-")) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
deb_version = `${version.replace("-", "~")}-${revision ?? 1}`;
}
else {
// check cmake version has tweak component
if (version.split(".").length == 4) {
if (version.endsWith(".0")) {
const pos = version.lastIndexOf(".0");
deb_version = `${version.substring(0, pos)}~dev-${revision ?? 1}`;
}
else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) {
const pos = version.lastIndexOf(".");
deb_version = `${version.substring(0, pos)}~${version.substring(pos + 1)}-${revision ?? 1}`;
}
}
}
return `${deb_version}`;
}
/**
* Check if Package is already published in crates.io
Expand Down
22 changes: 20 additions & 2 deletions dist/build-crates-standalone-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127521,8 +127521,26 @@ function buildDebian(path, target, version) {
* @returns Modified version.
*/
function toDebianVersion(version, revision) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
return `${version.replace("-", "~")}-${revision ?? 1}`;
let deb_version = version;
// Check if version is semver or cmake version
if (version.includes("-")) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
deb_version = `${version.replace("-", "~")}-${revision ?? 1}`;
}
else {
// check cmake version has tweak component
if (version.split(".").length == 4) {
if (version.endsWith(".0")) {
const pos = version.lastIndexOf(".0");
deb_version = `${version.substring(0, pos)}~dev-${revision ?? 1}`;
}
else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) {
const pos = version.lastIndexOf(".");
deb_version = `${version.substring(0, pos)}~${version.substring(pos + 1)}-${revision ?? 1}`;
}
}
}
return `${deb_version}`;
}
/**
* Check if Package is already published in crates.io
Expand Down
22 changes: 20 additions & 2 deletions dist/bump-crates-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -81243,8 +81243,26 @@ function buildDebian(path, target, version) {
* @returns Modified version.
*/
function toDebianVersion(version, revision) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
return `${version.replace("-", "~")}-${revision ?? 1}`;
let deb_version = version;
// Check if version is semver or cmake version
if (version.includes("-")) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
deb_version = `${version.replace("-", "~")}-${revision ?? 1}`;
}
else {
// check cmake version has tweak component
if (version.split(".").length == 4) {
if (version.endsWith(".0")) {
const pos = version.lastIndexOf(".0");
deb_version = `${version.substring(0, pos)}~dev-${revision ?? 1}`;
}
else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) {
const pos = version.lastIndexOf(".");
deb_version = `${version.substring(0, pos)}~${version.substring(pos + 1)}-${revision ?? 1}`;
}
}
}
return `${deb_version}`;
}
/**
* Check if Package is already published in crates.io
Expand Down
22 changes: 20 additions & 2 deletions dist/publish-crates-cargo-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -81132,8 +81132,26 @@ function buildDebian(path, target, version) {
* @returns Modified version.
*/
function toDebianVersion(version, revision) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
return `${version.replace("-", "~")}-${revision ?? 1}`;
let deb_version = version;
// Check if version is semver or cmake version
if (version.includes("-")) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
deb_version = `${version.replace("-", "~")}-${revision ?? 1}`;
}
else {
// check cmake version has tweak component
if (version.split(".").length == 4) {
if (version.endsWith(".0")) {
const pos = version.lastIndexOf(".0");
deb_version = `${version.substring(0, pos)}~dev-${revision ?? 1}`;
}
else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) {
const pos = version.lastIndexOf(".");
deb_version = `${version.substring(0, pos)}~${version.substring(pos + 1)}-${revision ?? 1}`;
}
}
}
return `${deb_version}`;
}
/**
* Check if Package is already published in crates.io
Expand Down
22 changes: 20 additions & 2 deletions dist/publish-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127516,8 +127516,26 @@ function buildDebian(path, target, version) {
* @returns Modified version.
*/
function toDebianVersion(version, revision) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
return `${version.replace("-", "~")}-${revision ?? 1}`;
let deb_version = version;
// Check if version is semver or cmake version
if (version.includes("-")) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
deb_version = `${version.replace("-", "~")}-${revision ?? 1}`;
}
else {
// check cmake version has tweak component
if (version.split(".").length == 4) {
if (version.endsWith(".0")) {
const pos = version.lastIndexOf(".0");
deb_version = `${version.substring(0, pos)}~dev-${revision ?? 1}`;
}
else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) {
const pos = version.lastIndexOf(".");
deb_version = `${version.substring(0, pos)}~${version.substring(pos + 1)}-${revision ?? 1}`;
}
}
}
return `${deb_version}`;
}
/**
* Check if Package is already published in crates.io
Expand Down
22 changes: 20 additions & 2 deletions dist/publish-crates-eclipse-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127597,8 +127597,26 @@ function buildDebian(path, target, version) {
* @returns Modified version.
*/
function toDebianVersion(version, revision) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
return `${version.replace("-", "~")}-${revision ?? 1}`;
let deb_version = version;
// Check if version is semver or cmake version
if (version.includes("-")) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
deb_version = `${version.replace("-", "~")}-${revision ?? 1}`;
}
else {
// check cmake version has tweak component
if (version.split(".").length == 4) {
if (version.endsWith(".0")) {
const pos = version.lastIndexOf(".0");
deb_version = `${version.substring(0, pos)}~dev-${revision ?? 1}`;
}
else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) {
const pos = version.lastIndexOf(".");
deb_version = `${version.substring(0, pos)}~${version.substring(pos + 1)}-${revision ?? 1}`;
}
}
}
return `${deb_version}`;
}
/**
* Check if Package is already published in crates.io
Expand Down
22 changes: 20 additions & 2 deletions dist/publish-crates-github-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127597,8 +127597,26 @@ function buildDebian(path, target, version) {
* @returns Modified version.
*/
function toDebianVersion(version, revision) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
return `${version.replace("-", "~")}-${revision ?? 1}`;
let deb_version = version;
// Check if version is semver or cmake version
if (version.includes("-")) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
deb_version = `${version.replace("-", "~")}-${revision ?? 1}`;
}
else {
// check cmake version has tweak component
if (version.split(".").length == 4) {
if (version.endsWith(".0")) {
const pos = version.lastIndexOf(".0");
deb_version = `${version.substring(0, pos)}~dev-${revision ?? 1}`;
}
else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) {
const pos = version.lastIndexOf(".");
deb_version = `${version.substring(0, pos)}~${version.substring(pos + 1)}-${revision ?? 1}`;
}
}
}
return `${deb_version}`;
}
/**
* Check if Package is already published in crates.io
Expand Down
22 changes: 20 additions & 2 deletions dist/publish-crates-homebrew-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127501,8 +127501,26 @@ function buildDebian(path, target, version) {
* @returns Modified version.
*/
function toDebianVersion(version, revision) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
return `${version.replace("-", "~")}-${revision ?? 1}`;
let deb_version = version;
// Check if version is semver or cmake version
if (version.includes("-")) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
deb_version = `${version.replace("-", "~")}-${revision ?? 1}`;
}
else {
// check cmake version has tweak component
if (version.split(".").length == 4) {
if (version.endsWith(".0")) {
const pos = version.lastIndexOf(".0");
deb_version = `${version.substring(0, pos)}~dev-${revision ?? 1}`;
}
else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) {
const pos = version.lastIndexOf(".");
deb_version = `${version.substring(0, pos)}~${version.substring(pos + 1)}-${revision ?? 1}`;
}
}
}
return `${deb_version}`;
}
/**
* Check if Package is already published in crates.io
Expand Down
20 changes: 18 additions & 2 deletions src/cargo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,24 @@ export function buildDebian(path: string, target: string, version: string) {
* @returns Modified version.
*/
export function toDebianVersion(version: string, revision?: number): string {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
return `${version.replace("-", "~")}-${revision ?? 1}`;
let deb_version = version;
diogomatsubara marked this conversation as resolved.
Show resolved Hide resolved
// Check if version is semver or cmake version
if (version.includes("-")) {
// HACK(fuzzypixelz): This is an oversimplification of the Debian Policy
deb_version = `${version.replace("-", "~")}-${revision ?? 1}`;
} else {
// check cmake version has tweak component
if (version.split(".").length == 4) {
if (version.endsWith(".0")) {
const pos = version.lastIndexOf(".0");
deb_version = `${version.substring(0, pos)}~dev-${revision ?? 1}`;
} else if (parseInt(version.substring(version.lastIndexOf(".") + 1)) > 0) {
const pos = version.lastIndexOf(".");
deb_version = `${version.substring(0, pos)}~${version.substring(pos + 1)}-${revision ?? 1}`;
diogomatsubara marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
return `${deb_version}`;
}

/**
Expand Down