Display current branch and version on the footer #10
|
@ -58,5 +58,13 @@ fn main() {
|
|||
.arg(asset_path(asset))
|
||||
.spawn()
|
||||
.unwrap();
|
||||
})
|
||||
});
|
||||
|
||||
let commit = Command::new("git")
|
||||
.args(&["rev-parse", "HEAD"])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
let commit = String::from_utf8(commit.stdout).unwrap();
|
||||
println!("cargo:rustc-env=COMMIT_HASH={commit}");
|
||||
}
|
|
@ -15,6 +15,18 @@ pub struct Redis {
|
|||
pub prefix: String
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct VersionData {
|
||||
pub commit: String
|
||||
}
|
||||
impl Default for VersionData {
|
||||
fn default() -> Self {
|
||||
VersionData {
|
||||
commit: env!("COMMIT_HASH").to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Env {
|
||||
pub logging: bool,
|
||||
|
@ -24,7 +36,8 @@ pub struct Env {
|
|||
pub filedir: String,
|
||||
pub instanceurl: String,
|
||||
pub uploadspath: String,
|
||||
pub confpath: String
|
||||
pub confpath: String,
|
||||
pub version: VersionData
|
||||
}
|
||||
|
||||
fn get_var<T: Into<String>, O: From<String>>(name: T) -> Result<O, String> {
|
||||
|
@ -140,7 +153,8 @@ pub fn loadenv() -> Result<Env, Box<dyn std::error::Error>> {
|
|||
return Err(format!("CONF_FILE is {}, which is not a file!", spath).into())
|
||||
}
|
||||
spath
|
||||
}
|
||||
},
|
||||
version: VersionData::default()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue