crate-git-revision

Crates.iocrate-git-revision
lib.rscrate-git-revision
version0.0.6
sourcesrc
created_at2022-10-19 22:06:09.951661
updated_at2023-02-17 00:38:53.178298
descriptionEmbed git revision into crates built and published.
homepagehttps://github.com/stellar/crate-git-revision
repositoryhttps://github.com/stellar/crate-git-revision
max_upload_size
id691905
size25,942
Stellar (Rust crate publisher) (stellar-crates)

documentation

README

crate-git-revision

Embed the git revision of a crate in its build.

Supports embedding the version from a local or remote git repository the build is occurring in, as well as when cargo install or depending on a crate published to crates.io.

It extracts the git revision in two ways:

  • From the .cargo_vcs_info.json file embedded in published crates.
  • From the git repository the build is occurring from in unpublished crates.

Injects an environment variable GIT_REVISION into the build that contains the full git revision, with a -dirty suffix if the working directory is dirty.

Requires the use of a build.rs build script. See Build Scripts for more details on how Rust build scripts work.

Examples

Add the following to the crate's Cargo.toml file:

[build_dependencies]
crate-git-revision = "0.0.2"

Add the following to the crate's build.rs file:

crate_git_revision::init();

Add the following to the crate's lib.rs or main.rs file:

pub const GIT_REVISION: &str = env!("GIT_REVISION");

License: Apache-2.0

Commit count: 15

cargo fmt