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

Allow message patch version #659

Closed
wants to merge 4 commits into from
Closed
Changes from all 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
18 changes: 8 additions & 10 deletions libraries/message/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,20 @@
fn current_crate_version() -> semver::Version {
let crate_version_raw = env!("CARGO_PKG_VERSION");
let crate_version = semver::Version::parse(crate_version_raw).unwrap();
crate_version

Check warning on line 25 in libraries/message/src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

returning the result of a `let` binding from a block
}

// Current version compatibility will makes dora message accept
// all messages from the same major and minor version and ignore patch version.
fn versions_compatible(
crate_version: &semver::Version,
specified_version: &semver::Version,
) -> Result<bool, String> {
let req = semver::VersionReq::parse(&crate_version.to_string()).map_err(|error| {
format!("failed to parse crate version `{crate_version}` as `VersionReq`: {error}")
})?;
let specified_dora_req = semver::VersionReq::parse(&specified_version.to_string())
.map_err(|error| {
format!(
"failed to parse specified dora version `{specified_version}` as `VersionReq`: {error}",
)
})?;
let matches = req.matches(&specified_version) || specified_dora_req.matches(crate_version);
let req = semver::VersionReq::parse(&format!(
"~{}.{}.0",
crate_version.major, crate_version.minor
))
.unwrap();
let matches = req.matches(&specified_version);

Check warning on line 39 in libraries/message/src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

this expression creates a reference which is immediately dereferenced by the compiler
Ok(matches)
}
Loading