#build-time #commit #latest #git-commit #static #variables #reporting

build git-latest-commit

Add data about the latest git commit for a project at build time, for run-time reporting

4 releases

Uses old Rust 2015

0.1.3 Nov 8, 2016
0.1.2 Nov 8, 2016
0.1.1 Oct 29, 2016
0.1.0 Oct 29, 2016

#44 in #reporting

ISC license

4KB
66 lines

git-latest-commit

Makes a file available to a Rust project at build time containing the latest commit's sha and summary as static vars.

Shamelessly adapted from cstorey/git-build-version.

Invoke this tool in your package build step. In Cargo.toml, add it as a build dep:

[package]
name = "something-gratuitously-mentioning-rust"
build = "build.rs"

[build-dependencies]
git-latest-commit = "0.1.3"

Then, in build.rs at the top level of your project:

extern crate git_latest_commit;

const PACKAGE_TOP_DIR : &'static str = ".";

fn main()
{
    git_latest_commit::write(PACKAGE_TOP_DIR).expect("Exporting git commit info.");
}

License

ISC

Dependencies

~9MB
~239K SLoC