Skip to content

Commit 693e9f3

Browse files
committed
fix: always attempt to fetch git info in build script
- Updated the build script to always try fetching git information. - If fetching fails, it falls back to using default values for version and build type.
1 parent 56e6319 commit 693e9f3

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

build.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ fn main() -> Result<(), Box<dyn Error>> {
7676
env::var("TARGET").unwrap()
7777
);
7878

79-
if let Ok(value) = env::var("BUILD_OTREE_WITH_GIT_INFO") {
80-
if value == "true" {
81-
return fetch_git_info();
82-
}
79+
// 始终尝试获取 git 信息,失败时使用默认值
80+
if let Err(_) = fetch_git_info() {
81+
let cargo_version = env!("CARGO_PKG_VERSION");
82+
println!("cargo:rustc-env=OTREE_VERSION={cargo_version}");
83+
println!("cargo:rustc-env=OTREE_BUILD_TYPE=stable");
84+
println!("cargo:rustc-env=OTREE_SHA=<unknown>");
8385
}
8486

85-
let cargo_version = env!("CARGO_PKG_VERSION");
86-
println!("cargo:rustc-env=OTREE_VERSION={cargo_version}");
87-
println!("cargo:rustc-env=OTREE_BUILD_TYPE=stable");
88-
println!("cargo:rustc-env=OTREE_SHA=<unknown>");
8987
Ok(())
9088
}

0 commit comments

Comments
 (0)