#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 82514/week @ 2024-07-20 68064/week @ 2024-07-27 66725/week @ 2024-08-03 72512/week @ 2024-08-10 71052/week @ 2024-08-17 75614/week @ 2024-08-24 76797/week @ 2024-08-31 81659/week @ 2024-09-07 79385/week @ 2024-09-14 82313/week @ 2024-09-21 84165/week @ 2024-09-28 89986/week @ 2024-10-05 90731/week @ 2024-10-12 101104/week @ 2024-10-19 82044/week @ 2024-10-26 79685/week @ 2024-11-02

370,119 downloads per month
Used in 173 crates (96 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

~230–670KB
~16K SLoC