Git Product home page Git Product logo

git-testament's Introduction

Git Testament

BSD 3 Clause Main build status Latest docs Crates.IO

git-testament is a library to embed a testament as to the state of a git working tree during the build of a Rust program. It uses the power of procedural macros to embed commit, tag, and working-tree-state information into your program when it is built. This can then be used to report version information.

use git_testament::{git_testament, render_testament};

git_testament!(TESTAMENT);

fn main() {
    println!("My version information: {}", render_testament!(TESTAMENT));
}

Reproducible builds

In the case that your build is not being done from a Git repository, you still want your testament to be useful to your users. Reproducibility of the binary is critical in that case. The Reproducible Builds team have defined a mechanism for this known as SOURCE_DATE_EPOCH which is an environment variable which can be set to ensure the build date is fixed for reproducibilty reasons. If you have no repo (or a repo but no commit) then git_testament!() will use the SOURCE_DATE_EPOCH environment variable (if present and parseable as a number of seconds since the UNIX epoch) to override now.

Use in no_std scenarios

This crate does not link to anything in the standard library, but it does rely by default on the alloc library being available. Disabling the alloc feature allows the crate to work in no_std environments where the alloc library is not available. You can still generate a GitTestament struct though it'll be less easy to work with. Instead it'd be recommended to use the git_testament_macros!() macro instead which provides a set of macros which produce string constants to use. This is less flexible/capable but can sometimes be easier to work with in these kinds of situations.

git-testament's People

Contributors

becominginsane avatar jyn514 avatar kinnison avatar tesuji avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.