[−][src]Struct git_sha1::GitSHA1
Implementations
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).
Example
GitSHA1::read().use_default("<empty>").set("GIT_SHA1"); // 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() {}
.
Note:
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]
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.
Note
The number of digits extracted is silently truncated to the maximum number of digits available in the Git SHA1.
Auto Trait Implementations
impl RefUnwindSafe for GitSHA1
[src]
impl Send for GitSHA1
[src]
impl Sync for GitSHA1
[src]
impl Unpin for GitSHA1
[src]
impl UnwindSafe for GitSHA1
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,