Skip to main content

horto_os_ui_shared/
build_info.rs

1//! Package version and git commit baked at compile time.
2
3/// Workspace package version (`Cargo.toml`).
4pub const VERSION: &str = env!("CARGO_PKG_VERSION");
5
6/// Short git SHA from build (`unknown` if unavailable); may end with `-dirty`.
7pub const GIT_COMMIT: &str = env!("GIT_COMMIT_HASH");
8
9/// Static label for clap `long_version` and UI footers: `0.1.0 (abc1234)`.
10pub const LONG_VERSION: &str = concat!(
11    env!("CARGO_PKG_VERSION"),
12    " (",
13    env!("GIT_COMMIT_HASH"),
14    ")"
15);
16
17/// Human footer line: `v0.1.0 (abc1234)`.
18#[must_use]
19pub fn footer_line() -> String {
20    format!("v{VERSION} ({GIT_COMMIT})")
21}
22
23#[cfg(test)]
24mod tests {
25    use super::*;
26
27    #[test]
28    fn labels_nonempty() {
29        assert_ne!(VERSION, "");
30        assert_ne!(GIT_COMMIT, "");
31        assert!(LONG_VERSION.contains(VERSION));
32        assert!(footer_line().starts_with('v'));
33    }
34}