Display current branch and version on the footer #10

Merged
blek merged 6 commits from display-version into 0.2-dev 2023-10-29 10:48:35 +01:00
2 changed files with 25 additions and 3 deletions
Showing only changes of commit d09f88f7fa - Show all commits

View File

@ -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}");
}

View File

@ -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()
}
)
}