mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-06 08:18:58 +00:00
Move git SHA/build date from fabro-util to fabro-cli build.rs
fabro-util is a low-level crate depended on by almost everything, so its build.rs reruns cascaded through the whole workspace. fabro-cli is the leaf binary — nothing depends on it, so rebuilds are limited to just that one crate. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cdbfc72719
commit
1b3d3d900b
7 changed files with 37 additions and 32 deletions
|
|
@ -53,6 +53,9 @@ axum = "0.8"
|
|||
open = "5"
|
||||
serde_json.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
chrono = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
assert_cmd = "2"
|
||||
insta = { workspace = true }
|
||||
|
|
|
|||
23
lib/crates/fabro-cli/build.rs
Normal file
23
lib/crates/fabro-cli/build.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
fn main() {
|
||||
println!("cargo:rerun-if-changed=../../../.git/HEAD");
|
||||
|
||||
let sha = std::process::Command::new("git")
|
||||
.args(["rev-list", "-1", "HEAD"])
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|o| {
|
||||
if o.status.success() {
|
||||
String::from_utf8(o.stdout)
|
||||
.ok()
|
||||
.map(|s| s.trim().to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let short_sha = if sha.len() >= 7 { &sha[..7] } else { &sha };
|
||||
println!("cargo:rustc-env=FABRO_GIT_SHA={short_sha}");
|
||||
|
||||
let build_date = chrono::Utc::now().format("%Y-%m-%d").to_string();
|
||||
println!("cargo:rustc-env=FABRO_BUILD_DATE={build_date}");
|
||||
}
|
||||
|
|
@ -11,8 +11,17 @@ use anyhow::Result;
|
|||
use clap::{Parser, Subcommand};
|
||||
use tracing::debug;
|
||||
|
||||
const LONG_VERSION: &str = concat!(
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
" (",
|
||||
env!("FABRO_GIT_SHA"),
|
||||
" ",
|
||||
env!("FABRO_BUILD_DATE"),
|
||||
")"
|
||||
);
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "fabro", version, long_version = fabro_util::version::LONG_VERSION.as_str())]
|
||||
#[command(name = "fabro", version, long_version = LONG_VERSION)]
|
||||
struct Cli {
|
||||
/// Enable DEBUG-level logging (default is INFO)
|
||||
#[arg(long, global = true)]
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ git2.workspace = true
|
|||
[build-dependencies]
|
||||
toml = "0.8"
|
||||
serde = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
insta = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -53,28 +53,6 @@ fn escape_rust_string(s: &str) -> String {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
// Emit git SHA and build date for version info
|
||||
println!("cargo:rerun-if-changed=../../../.git/HEAD");
|
||||
let sha = std::process::Command::new("git")
|
||||
.args(["rev-list", "-1", "HEAD"])
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|o| {
|
||||
if o.status.success() {
|
||||
String::from_utf8(o.stdout)
|
||||
.ok()
|
||||
.map(|s| s.trim().to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let short_sha = if sha.len() >= 7 { &sha[..7] } else { &sha };
|
||||
println!("cargo:rustc-env=FABRO_GIT_SHA={short_sha}");
|
||||
|
||||
let build_date = chrono::Utc::now().format("%Y-%m-%d").to_string();
|
||||
println!("cargo:rustc-env=FABRO_BUILD_DATE={build_date}");
|
||||
|
||||
println!("cargo:rerun-if-changed=data/gitleaks.toml");
|
||||
|
||||
let toml_path = Path::new("data/gitleaks.toml");
|
||||
|
|
|
|||
|
|
@ -1,8 +1 @@
|
|||
use std::sync::LazyLock;
|
||||
|
||||
pub const FABRO_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
pub const FABRO_GIT_SHA: &str = env!("FABRO_GIT_SHA");
|
||||
pub const FABRO_BUILD_DATE: &str = env!("FABRO_BUILD_DATE");
|
||||
|
||||
pub static LONG_VERSION: LazyLock<String> =
|
||||
LazyLock::new(|| format!("{FABRO_VERSION} ({FABRO_GIT_SHA} {FABRO_BUILD_DATE})"));
|
||||
|
|
|
|||
|
|
@ -787,7 +787,7 @@ impl ProgressUI {
|
|||
}
|
||||
|
||||
pub fn show_version(&mut self) {
|
||||
let version = fabro_util::version::LONG_VERSION.as_str();
|
||||
let version = fabro_util::version::FABRO_VERSION;
|
||||
match &self.renderer {
|
||||
ProgressRenderer::Tty(tty) => {
|
||||
let bar = tty.multi.add(ProgressBar::new_spinner());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue