[][src]Struct git_sha1::GitSHA1

pub struct GitSHA1 { /* fields omitted */ }


impl GitSHA1[src]

pub fn use_default(self, default: &str) -> Self[src]

Although designed with Git in mind, your crate may be compiled from source without being in a Git repository. This lets you define the value which is used instead of the real Git SHA1 as a drop-in replacement. The default value is "" (an empty string).


// will use: GIT_SHA1="<empty>"

pub fn read() -> Self[src]

Read current Git SHA1 by running git rev-parse HEAD.

This only retrieves the SHA1 from git. Use set(name) to pass compile-time environment variable to cargo-build. Afterwards it can be read from your source files.

If the current crate is not a git repository, the read will silently fail and the returned string in the end will be substituded by a default value.

pub fn from_env(name: &str) -> Self[src]

Read the comiple-time environment variable from carto-build. This can be used during runtime, i.e. in fn main() {}.


You can read the Git SHA1 statically using env!:

// "GIT_SHA1" set in `build.rs`
const GIT_SHA1: &'static str = env!("GIT_SHA1");

pub fn set(&self, name: &str)[src]

Generate cargo environment variable for long Git SHA1.



pub fn long(&self) -> String[src]

Return the complete SHA1 as a String.

pub fn short(&self, count: usize) -> String[src]

Return a subset of digits (short sha) as a String.


The number of digits extracted is silently truncated to the maximum number of digits available in the Git SHA1.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.