Function grev::git_revision_auto
source · Expand description
Retrieve a git revision identifier that either includes the tag we
are on or the shortened SHA-1. It also contains an indication (+
)
whether local changes were present.
This function is meant to be run from a Cargo build script. It takes
care of printing necessary rerun-if-changed
directives to stdout
as expected by cargo
. As a result, callers are advised to invoke
it only once and cache the result.
The provided directory
is a path expected to point somewhere into
the git repository in question. Typically, it can simply be set to
the value of the CARGO_MANIFEST_DIR
variable, as set by Cargo.
The function works on a best-effort basis: if git is not available
or no git repository is present, it will fail gracefully by
returning Ok(None)
.