mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-27 05:51:01 +00:00
Fall back to default unknown COMMIT_ID and BUILD_REL_DATE if unable to find commit in repo
This commit is contained in:
parent
888f98e2f0
commit
e0695b637f
1 changed files with 10 additions and 8 deletions
|
@ -93,19 +93,21 @@ pub fn get_info() {
|
||||||
// Otherwise use a 'release.txt' file as fallback, or report the current
|
// Otherwise use a 'release.txt' file as fallback, or report the current
|
||||||
// date and an unknown revision.
|
// date and an unknown revision.
|
||||||
if let Ok(repo) = repo {
|
if let Ok(repo) = repo {
|
||||||
let commit = find_last_commit(&repo).expect("Couldn't find last commit");
|
if let Ok(commit) = find_last_commit(&repo) {
|
||||||
commit_id = oid_to_short_sha(commit.id());
|
commit_id = oid_to_short_sha(commit.id());
|
||||||
let timestamp = commit.time().seconds();
|
let timestamp = commit.time().seconds();
|
||||||
let dt = chrono::Utc.timestamp(timestamp, 0);
|
let dt = chrono::Utc.timestamp(timestamp, 0);
|
||||||
commit_date = dt.format("%Y-%m-%d").to_string()
|
commit_date = dt.format("%Y-%m-%d").to_string()
|
||||||
|
}
|
||||||
} else if let Ok(release_file) = fs::File::open(release_file) {
|
} else if let Ok(release_file) = fs::File::open(release_file) {
|
||||||
let mut cargo_toml = crate_dir;
|
let mut cargo_toml = crate_dir;
|
||||||
cargo_toml.push("Cargo.toml");
|
cargo_toml.push("Cargo.toml");
|
||||||
|
|
||||||
let cargo_toml = fs::File::open(cargo_toml).expect("Can't open Cargo.toml");
|
if let Ok(cargo_toml) = fs::File::open(cargo_toml) {
|
||||||
commit_date = read_release_date(cargo_toml, release_file);
|
commit_date = read_release_date(cargo_toml, release_file);
|
||||||
commit_id = "RELEASE".into();
|
commit_id = "RELEASE".into();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
println!("cargo:rustc-env=COMMIT_ID={}", commit_id);
|
println!("cargo:rustc-env=COMMIT_ID={}", commit_id);
|
||||||
println!("cargo:rustc-env=BUILD_REL_DATE={}", commit_date);
|
println!("cargo:rustc-env=BUILD_REL_DATE={}", commit_date);
|
||||||
|
|
Loading…
Reference in a new issue