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

Handle leaking of prerelease into alpha version #1953

Merged
merged 1 commit into from
Apr 25, 2023
Merged
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: 17 additions & 1 deletion crates/re_build_info/src/crate_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl CrateVersion {
pub fn from_bytes([major, minor, patch, suffix_byte]: [u8; 4]) -> Self {
let is_alpha = (suffix_byte & IS_ALPHA_BIT) != 0;
let is_prerelease = (suffix_byte & IS_PRERELEASE_BIT) != 0;
let alpha_version = suffix_byte & 0b0111_1111;
let alpha_version = suffix_byte & !(IS_ALPHA_BIT | IS_PRERELEASE_BIT);

Self {
major,
Expand Down Expand Up @@ -273,6 +273,22 @@ fn test_format_parse_roundtrip() {
}
}

#[test]
fn test_format_parse_roundtrip_bytes() {
let parse = CrateVersion::parse;
for version in [
"0.2.0",
"1.2.3",
"12.23.24",
"12.23.24-alpha.31",
"12.23.24-alpha.31+foo",
] {
let version = parse(version);
let bytes = version.to_bytes();
assert_eq!(CrateVersion::from_bytes(bytes), version);
}
}

#[test]
fn test_compatibility() {
fn are_compatible(a: &str, b: &str) -> bool {
Expand Down