mirror of
https://github.com/actionbook/actionbook.git
synced 2026-09-19 03:28:06 +08:00
fd2ed699e6
- build.rs now uses `git rev-parse --git-dir` to find the actual .git/HEAD path, fixing stale BUILD_VERSION in monorepo layouts - Add check_version on the delayed connect path (auto-start loop) so connecting to an outdated daemon after transient failure also triggers VERSION_MISMATCH Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
34 lines
1.0 KiB
Rust
34 lines
1.0 KiB
Rust
fn main() {
|
|
let hash = std::process::Command::new("git")
|
|
.args(["rev-parse", "--short", "HEAD"])
|
|
.output()
|
|
.ok()
|
|
.and_then(|o| String::from_utf8(o.stdout).ok())
|
|
.unwrap_or_default()
|
|
.trim()
|
|
.to_string();
|
|
|
|
let pkg_version = std::env::var("CARGO_PKG_VERSION").unwrap_or_default();
|
|
let build_version = if hash.is_empty() {
|
|
pkg_version
|
|
} else {
|
|
format!("{pkg_version}-{hash}")
|
|
};
|
|
|
|
println!("cargo:rustc-env=BUILD_VERSION={build_version}");
|
|
|
|
// Resolve repo root .git/HEAD for monorepo — relative paths are resolved
|
|
// from the package directory (packages/cli-v2/), not the repo root.
|
|
let git_dir = std::process::Command::new("git")
|
|
.args(["rev-parse", "--git-dir"])
|
|
.output()
|
|
.ok()
|
|
.and_then(|o| String::from_utf8(o.stdout).ok())
|
|
.unwrap_or_default()
|
|
.trim()
|
|
.to_string();
|
|
if !git_dir.is_empty() {
|
|
println!("cargo:rerun-if-changed={git_dir}/HEAD");
|
|
}
|
|
}
|