Provide the current Git commit SHA1 during build.
When building crates from a Git repository it is often desirable to extract the current version number in form of the Git SHA1 to be displayed. This crate extracts the current Git SHA1 during build time and makes it accessible as an environment variable.
If the crate is currently built without access to the Git SHA1 (i. e. it was extracted
from a tar-archive, or Git is not installed), instead of failing, it falls back on a
default value. This value defaults to "", but can be changed with the
use_default()
method.
Example
In build.rs
:
use GitSHA1;
In main.rs
:
use GitSHA1;
// either as static &str:
static SHA1: &str = env!;
// or during runtime: