Add build script to make git version available in code

Signed-off-by: pep <pep@bouah.net>
This commit is contained in:
pep 2026-01-08 23:16:01 +01:00
commit 457c40bffe
3 changed files with 57 additions and 0 deletions

View file

@ -23,6 +23,14 @@ use xmpp::jid::{BareJid, ResourcePart};
use crate::error::Error;
const MAYBE_VERSION: &'static str = include_str!(concat!(env!("OUT_DIR"), "/GIT_COMMIT"));
const fn version() -> Option<&'static str> {
match MAYBE_VERSION {
v if v.is_empty() => None,
v => Some(v),
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Config {
/// Accounts trusted for admin tasks
@ -50,6 +58,11 @@ pub struct Config {
/// HTTP Webhook listening address and port, e.g., 127.0.0.1:1234 or [::1]:1234
#[serde(default = "Config::default_addr")]
pub addr: SocketAddr,
/// Software version
#[serde(skip)]
#[serde(default = "version")]
pub version: Option<&'static str>,
}
impl Config {