2020-08-04 07:44:53 +00:00
|
|
|
use git_version::git_version;
|
|
|
|
use target_info::Target;
|
|
|
|
|
|
|
|
/// Returns the current version of this build of Lighthouse.
|
|
|
|
///
|
|
|
|
/// A plus-sign (`+`) is appended to the git commit if the tree is dirty.
|
|
|
|
///
|
|
|
|
/// ## Example
|
|
|
|
///
|
|
|
|
/// `Lighthouse/v0.2.0-1419501f2+`
|
|
|
|
pub const VERSION: &str = git_version!(
|
2021-02-23 23:31:37 +00:00
|
|
|
args = ["--always", "--dirty=+", "--abbrev=7", "--exclude=*"],
|
2021-02-22 06:21:38 +00:00
|
|
|
prefix = "Lighthouse/v1.1.3-",
|
2020-08-04 07:44:53 +00:00
|
|
|
fallback = "unknown"
|
|
|
|
);
|
|
|
|
|
|
|
|
/// Returns `VERSION`, but with platform information appended to the end.
|
|
|
|
///
|
|
|
|
/// ## Example
|
|
|
|
///
|
|
|
|
/// `Lighthouse/v0.2.0-1419501f2+/x86_64-linux`
|
|
|
|
pub fn version_with_platform() -> String {
|
|
|
|
format!("{}/{}-{}", VERSION, Target::arch(), Target::os())
|
|
|
|
}
|
2021-02-23 23:31:37 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod test {
|
|
|
|
use super::*;
|
|
|
|
use regex::Regex;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn version_formatting() {
|
|
|
|
let re = Regex::new(r"^Lighthouse/v[0-9]+\.[0-9]+\.[0-9]+(-rc.[0-9])?-[[:xdigit:]]{7}\+?$")
|
|
|
|
.unwrap();
|
|
|
|
assert!(re.is_match(VERSION), VERSION);
|
|
|
|
}
|
|
|
|
}
|