#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

#11 in Build Utils

Download history 44572/week @ 2023-12-06 38868/week @ 2023-12-13 27626/week @ 2023-12-20 22280/week @ 2023-12-27 39825/week @ 2024-01-03 52081/week @ 2024-01-10 57681/week @ 2024-01-17 60302/week @ 2024-01-24 64976/week @ 2024-01-31 60148/week @ 2024-02-07 64549/week @ 2024-02-14 67755/week @ 2024-02-21 77384/week @ 2024-02-28 68036/week @ 2024-03-06 70994/week @ 2024-03-13 55246/week @ 2024-03-20

284,298 downloads per month
Used in 124 crates (77 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

~315–770KB
~18K SLoC