Added git hash used for the build in the footer

master
Wynd 2026-03-02 00:23:00 +02:00
parent 67027a3282
commit 791b55b367
4 changed files with 26 additions and 2 deletions

22
build.rs 100644
View File

@ -0,0 +1,22 @@
use std::{env, fs, path::Path};
fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let path = Path::new(&out_dir).join("git_hash.rs");
let git_output = std::process::Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.unwrap()
.stdout;
let last_hash = String::from_utf8(git_output).unwrap();
let last_hash = last_hash.trim();
fs::write(
&path,
format!("pub const GIT_HASH: &str = \"{last_hash}\";"),
)
.unwrap();
}

View File

@ -2,7 +2,7 @@ set export
set quiet set quiet
set dotenv-load set dotenv-load
#[arg("assets", long="assets")] [arg("assets", long="assets")]
build assets="false": build assets="false":
#!/usr/bin/env bash #!/usr/bin/env bash
mkdir -p ./out mkdir -p ./out

View File

@ -13,6 +13,8 @@ use tracing_subscriber::EnvFilter;
mod common; mod common;
include!(concat!(env!("OUT_DIR"), "/git_hash.rs"));
#[cfg(feature = "bbs")] #[cfg(feature = "bbs")]
mod bbs; mod bbs;

View File

@ -11,7 +11,7 @@
<body> <body>
<div id="content">{% block content %}{% endblock %}</div> <div id="content">{% block content %}{% endblock %}</div>
<footer> <footer>
<p>v{{ crate::VERSION }}</p> <p>v{{ crate::VERSION +}} - {{+ crate::GIT_HASH }}</p>
</footer> </footer>
</body> </body>
</html> </html>