Add git_tag()

This commit is contained in:
ChJR
2019-09-22 17:23:29 +09:00
parent c7341d60ec
commit fd64763088
2 changed files with 9 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ fn main() {
"cargo:rustc-env=RUSTPYTHON_GIT_TIMESTAMP={}",
git_timestamp()
);
println!("cargo:rustc-env=RUSTPYTHON_GIT_TAG={}", git_tag());
println!("cargo:rustc-env=RUSTPYTHON_GIT_BRANCH={}", git_branch());
}
@@ -17,6 +18,10 @@ fn git_timestamp() -> String {
git(&["log", "-1", "--format=%cd"])
}
fn git_tag() -> String {
git(&["describe", "--all", "--always", "--dirty"])
}
fn git_branch() -> String {
git(&["rev-parse", "--abbrev-ref", "HEAD"])
}

View File

@@ -38,6 +38,10 @@ pub fn get_git_revision() -> String {
option_env!("RUSTPYTHON_GIT_HASH").unwrap_or("").to_string()
}
pub fn get_git_tag() -> String {
option_env!("RUSTPYTHON_GIT_TAG").unwrap_or("").to_string()
}
pub fn get_git_branch() -> String {
option_env!("RUSTPYTHON_GIT_BRANCH")
.unwrap_or("")