Skip to content

Commit

Permalink
Fix handling of epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Jul 17, 2024
1 parent b2add94 commit 2661c31
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ impl FromStr for Version {

impl std::fmt::Display for Version {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(&self.upstream_version)?;
if let Some(epoch) = self.epoch.as_ref() {
write!(f, ":{}", epoch)?;
write!(f, "{}:", epoch)?;
}
f.write_str(&self.upstream_version)?;
if let Some(debian_revision) = self.debian_revision.as_ref() {
write!(f, "-{}", debian_revision)?;
}
Expand Down Expand Up @@ -503,6 +503,15 @@ mod tests {
}
.to_string()
);
assert_eq!(
"1:1.0",
Version {
epoch: Some(1),
upstream_version: "1.0".to_string(),
debian_revision: None,
}
.to_string()
);
}

#[test]
Expand Down

0 comments on commit 2661c31

Please sign in to comment.