diff --git a/libraries/message/src/lib.rs b/libraries/message/src/lib.rs index a435b34f1..2971cf0f7 100644 --- a/libraries/message/src/lib.rs +++ b/libraries/message/src/lib.rs @@ -25,19 +25,17 @@ fn current_crate_version() -> semver::Version { crate_version } +// 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 { - 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); Ok(matches) }