Add git hash info

This commit is contained in:
GitHub
2023-01-18 17:39:07 +08:00
parent c63da05b72
commit c31c7522df
4 changed files with 8 additions and 8 deletions

View File

@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Add git hash info
- Add git commit hash
## [0.2.8] - 2023-01-17

View File

@@ -6,13 +6,13 @@ fn main() {
_ => {}
}
let mut git_hash = match Command::new("git").args(["rev-parse", "HEAD"]).output() {
let mut git_commit = 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}");
git_commit.truncate(7);
println!("cargo:rustc-env=GIT_COMMIT={git_commit}");
}

View File

@@ -296,7 +296,7 @@ struct Claim {
session_id: String,
}
use crate::{config::CONFIG, error::AppError, GIT_HASH, VERSION};
use crate::{config::CONFIG, error::AppError, GIT_COMMIT, VERSION};
use askama::Template;
use axum::{
async_trait,
@@ -955,7 +955,7 @@ impl<'a> PageData<'a> {
has_unread,
sha256: &CURRENT_SHA256,
version: VERSION,
git_commit: GIT_HASH,
git_commit: GIT_COMMIT,
footer_links,
}
}

View File

@@ -22,7 +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");
const GIT_COMMIT: &str = env!("GIT_COMMIT");
static IS_DEBUG: Lazy<bool> =
Lazy::new(|| matches!(std::env::var("PROFILE"), Ok(key) if key.as_str() == "debug"));
@@ -35,7 +35,7 @@ async fn main() -> Result<(), AppError> {
info!("sha256: {}", *CURRENT_SHA256);
info!(VERSION);
info!(GIT_HASH);
info!(GIT_COMMIT);
let db_url = &CONFIG.db;
let config = sled::Config::default().path(db_url).use_compression(true);