mirror of
https://github.com/freedit-org/freedit.git
synced 2026-01-09 12:38:04 -05:00
Add git hash info
This commit is contained in:
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- Add git hash info
|
||||
|
||||
## [0.2.8] - 2023-01-17
|
||||
|
||||
### Added
|
||||
|
||||
12
build.rs
12
build.rs
@@ -1,6 +1,18 @@
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
match std::env::var("PROFILE") {
|
||||
Ok(key) if key.as_str() == "debug" => println!("cargo:rustc-env=PROFILE=debug"),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let mut git_hash = match Command::new("git").args(["rev-parse", "HEAD"]).output() {
|
||||
Ok(output) if !output.stdout.is_empty() => {
|
||||
String::from_utf8_lossy(&output.stdout).to_string()
|
||||
}
|
||||
_ => "not found".into(),
|
||||
};
|
||||
|
||||
git_hash.truncate(7);
|
||||
println!("cargo:rustc-env=GIT_HASH={git_hash}");
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ struct Claim {
|
||||
session_id: String,
|
||||
}
|
||||
|
||||
use crate::{config::CONFIG, error::AppError, VERSION};
|
||||
use crate::{config::CONFIG, error::AppError, GIT_HASH, VERSION};
|
||||
use askama::Template;
|
||||
use axum::{
|
||||
async_trait,
|
||||
@@ -929,6 +929,7 @@ struct PageData<'a> {
|
||||
has_unread: bool,
|
||||
sha256: &'a str,
|
||||
version: &'a str,
|
||||
git_commit: &'a str,
|
||||
footer_links: Vec<(&'a str, &'a str)>,
|
||||
}
|
||||
|
||||
@@ -954,6 +955,7 @@ impl<'a> PageData<'a> {
|
||||
has_unread,
|
||||
sha256: &CURRENT_SHA256,
|
||||
version: VERSION,
|
||||
git_commit: GIT_HASH,
|
||||
footer_links,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ use tracing::{error, info};
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
const GIT_HASH: &str = env!("GIT_HASH");
|
||||
static IS_DEBUG: Lazy<bool> =
|
||||
Lazy::new(|| matches!(std::env::var("PROFILE"), Ok(key) if key.as_str() == "debug"));
|
||||
|
||||
@@ -34,6 +35,7 @@ async fn main() -> Result<(), AppError> {
|
||||
|
||||
info!("sha256: {}", *CURRENT_SHA256);
|
||||
info!(VERSION);
|
||||
info!(GIT_HASH);
|
||||
|
||||
let db_url = &CONFIG.db;
|
||||
let config = sled::Config::default().path(db_url).use_compression(true);
|
||||
|
||||
@@ -130,8 +130,9 @@
|
||||
{% for footer_link in page_data.footer_links %}
|
||||
<p><a href="{{footer_link.1}}" target="_blank">{{footer_link.0|capitalize}}</a></p>
|
||||
{% endfor %}
|
||||
<p><small>version: {{page_data.version}}</small></p>
|
||||
<p><small>version: <a href="https://github.com/freedit-org/freedit/releases/tag/v{{page_data.version}}">v{{page_data.version}}</a></small></p>
|
||||
<p><small>sha256: {{page_data.sha256|truncate(10)}}</small></p>
|
||||
<p><small>commit: <a href="https://github.com/freedit-org/freedit/commit/{{page_data.git_commit}}">{{page_data.git_commit}}</a></small></p>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user