#git #version #build

build git-version

Compile the git version (tag name, or hash otherwise) and dirty state into your program

10 releases

0.3.9 Dec 13, 2023
0.3.8 Nov 15, 2023
0.3.5 Jul 22, 2021
0.3.4 Jan 9, 2020
0.2.1 Sep 23, 2018

#9 in Build Utils

Download history 75683/week @ 2024-08-22 73040/week @ 2024-08-29 81849/week @ 2024-09-05 80833/week @ 2024-09-12 79686/week @ 2024-09-19 85014/week @ 2024-09-26 88800/week @ 2024-10-03 87614/week @ 2024-10-10 95917/week @ 2024-10-17 91507/week @ 2024-10-24 79856/week @ 2024-10-31 76484/week @ 2024-11-07 82786/week @ 2024-11-14 80420/week @ 2024-11-21 74905/week @ 2024-11-28 73349/week @ 2024-12-05

325,260 downloads per month
Used in 185 crates (104 directly)

BSD-2-Clause

6KB

git-version

Embed git information in your code at compile-time.

use git_version::git_version;
const GIT_VERSION: &str = git_version!();

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

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

You can also get the version information for all submodules:

use git_version::git_submodule_versions;
const GIT_SUBMODULE_VERSIONS: &[(&str, &str)] = &git_submodule_versions!();

for (path, version) in GIT_SUBMODULE_VERSIONS {
    println!("{path}: {version}");
}

License: BSD-2-Clause


lib.rs:

Embed git information in your code at compile-time.

use git_version::git_version;
const GIT_VERSION: &str = git_version!();

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

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

You can also get the version information for all submodules:

use git_version::git_submodule_versions;
const GIT_SUBMODULE_VERSIONS: &[(&str, &str)] = &git_submodule_versions!();

for (path, version) in GIT_SUBMODULE_VERSIONS {
    println!("{path}: {version}");
}

Dependencies

~220–660KB
~16K SLoC