Crate git_version[][src]

Use this library in your build.rs script:

extern crate git_version;
fn main() { git_version::set_env(); }

Then you can use env!("VERSION") to get the version number in your code. The version number will be based on the relevant git tag (if any), and git commit hash if there is no exactly matching tag. See git help describe.

The version number will have a -modified suffix if your git worktree had untracked or changed files.

Does not depend on libgit, but simply uses the git binary directly. So you must have git installed somewhere in your PATH.

Functions

set_env

Instruct cargo to set the VERSION environment variable to the version as indicated by git describe --always --dirty=-modified.

set_env_with_name

Same as set_env, but using name as environment variable.