Skip to content

Commit

Permalink
Handle leaking of prerelease into alpha version (#1953)
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs authored Apr 25, 2023
1 parent eef4758 commit ad46760
Showing 1 changed file with 17 additions and 1 deletion.
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

0 comments on commit ad46760

Please sign in to comment.