Fix commit branch when not in pull request

This commit is contained in:
0hypercube 2023-08-23 21:54:33 +01:00
parent 237e97f033
commit 2d99d4bee1
1 changed files with 3 additions and 4 deletions

View File

@ -17,9 +17,8 @@ fn main() {
// They are accessed with the `env!("...")` macro in the codebase.
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_DATE={}", git_command(&["log", "-1", "--format=%cd"]));
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_HASH={}", git_command(&["rev-parse", "HEAD"]));
println!(
"cargo:rustc-env=GRAPHITE_GIT_COMMIT_BRANCH={}",
std::env::var("GITHUB_HEAD_REF").unwrap_or_else(|_| git_command(&["name-rev", "--name-only", "HEAD"]))
);
let branch = std::env::var("GITHUB_HEAD_REF").unwrap_or_default();
let branch = if branch.is_empty() { git_command(&["name-rev", "--name-only", "HEAD"]) } else { branch };
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_BRANCH={}", branch);
println!("cargo:rustc-env=GRAPHITE_RELEASE_SERIES={}", GRAPHITE_RELEASE_SERIES);
}