Struct vergen::Git

source ·
pub struct Git { /* private fields */ }
Expand description

Configuration for the VERGEN_GIT_* instructions

Instructions

The following instructions can be generated:

InstructionDefault
cargo:rustc-env=VERGEN_GIT_BRANCH=feature/git2*
cargo:rustc-env=VERGEN_GIT_COMMIT_COUNT=330
cargo:rustc-env=VERGEN_GIT_COMMIT_DATE=2021-02-12
cargo:rustc-env=VERGEN_GIT_COMMIT_TIME=01:54:15
cargo:rustc-env=VERGEN_GIT_COMMIT_TIMESTAMP=2021-02-12T01:54:15.134750+00:00*
cargo:rustc-env=VERGEN_GIT_SEMVER=v3.2.0-86-g95fc0f5d*
cargo:rustc-env=VERGEN_GIT_SEMVER_LIGHTWEIGHT=feature-test
cargo:rustc-env=VERGEN_GIT_SHA=95fc0f5d066710f16e0c23ce3239d6e040abca0d*
cargo:rustc-env=VERGEN_GIT_SHA_SHORT=95fc0f5
cargo:rerun-if-changed=/Users/yoda/projects/rust-lang/vergen/.git/HEAD*
cargo:rerun-if-changed=/Users/yoda/projects/rust-lang/vergen/.git/refs/heads/feature/git2*
  • If the branch field is false, the VERGEN_GIT_BRANCH instruction will not be generated.
  • If the commit_count field is false, the VERGEN_GIT_COMMIT_COUNT instruction will not be generated.
  • If the commit_timestamp field is false, the date/time instructions will not be generated.
  • If the rerun_on_head_changed field is false, the cargo:rerun-if-changed instructions will not be generated.
  • If the semver field is false, the VERGEN_GIT_SEMVER instruction will not be generated.
  • If the sha field is false, the VERGEN_GIT_SHA instruction will not be generated.
  • NOTE - The SHA defaults to the Normal variant, but can be changed via the sha_kind field.
  • NOTE - The SemVer defaults to the Normal variant, but can be changed via the semver_kind field.
  • NOTE - The SemVer is only useful if you have tags on your repository. If your repository has no tags, this will default to CARGO_PKG_VERSION.
  • NOTE - You can add a -dirty flag to the SemVer output via the semver_dirty field.
  • NOTE - The Lightweight variant will only differ from the Normal variant if you use lightweight tags in your repository.
  • NOTE - By default, the date/time related instructions will use UTC.
  • NOTE - The date/time instruction output is determined by the kind field and can be any combination of the three.
  • NOTE - If the rerun_on_head_chaged instructions are enabled, cargo will re-run the build script when either <gitpath>/HEAD or the file that <gitpath>/HEAD points at changes.
  • NOTE - Even if a project is developed in a git repository, the repository is not always present with the source code, e.g. in a source tarball. By default, vergen returns an Error in this case. To keep processing other sections, set Git::skip_if_error to true.

Example

use vergen::{vergen, Config};
use vergen::{ShaKind, SemverKind};

let mut config = Config::default();
// Change the SHA output to the short variant
*config.git_mut().sha_kind_mut() = ShaKind::Short;
// Change the SEMVER output to the lightweight variant
*config.git_mut().semver_kind_mut() = SemverKind::Lightweight;
// Add a `-dirty` flag to the SEMVER output
*config.git_mut().semver_dirty_mut() = Some("-dirty");

// Generate the instructions
vergen(config)?;

Implementations§

source§

impl Git

source

pub fn enabled_mut(&mut self) -> &mut bool

Enable/Disable the git output

source

pub fn base_dir_mut(&mut self) -> &mut Option<PathBuf>

Optional git base directory

source

pub fn branch_mut(&mut self) -> &mut bool

Enable/Disable the VERGEN_GIT_BRANCH instruction

source

pub fn commit_author_mut(&mut self) -> &mut bool

Enable/Disable the VERGEN_GIT_COMMIT_AUTHOR_NAME, VERGEN_GIT_COMMIT_AUTHOR_EMAIL

source

pub fn commit_count_mut(&mut self) -> &mut bool

Enable/Disable the VERGEN_GIT_COMMIT_COUNT

source

pub fn commit_message_mut(&mut self) -> &mut bool

Enable/Disable the VERGEN_GIT_COMMIT_MESSAGE

source

pub fn commit_timestamp_mut(&mut self) -> &mut bool

Enable/Disable the VERGEN_GIT_COMMIT_DATE, VERGEN_GIT_COMMIT_TIME, and VERGEN_GIT_COMMIT_TIMESTAMP instructions

source

pub fn commit_timestamp_timezone_mut(&mut self) -> &mut TimeZone

The timezone to use for the date/time instructions.

source

pub fn commit_timestamp_kind_mut(&mut self) -> &mut TimestampKind

The kind of date/time instructions to output.

source

pub fn rerun_on_head_change_mut(&mut self) -> &mut bool

Enable/Disable the cargo:rerun-if-changed instructions

source

pub fn semver_mut(&mut self) -> &mut bool

Enable/Disable the VERGEN_GIT_SEMVER instruction

source

pub fn semver_kind_mut(&mut self) -> &mut SemverKind

The kind of semver instruction to output.

source

pub fn semver_dirty_mut(&mut self) -> &mut Option<&'static str>

Enable/Disable the -dirty flag on VERGEN_GIT_SEMVER* output

source

pub fn sha_mut(&mut self) -> &mut bool

Enable/Disable the VERGEN_GIT_SHA instruction

source

pub fn sha_kind_mut(&mut self) -> &mut ShaKind

The kind of SHA instruction to output.

source

pub fn skip_if_error_mut(&mut self) -> &mut bool

Enable/Disable skipping Git if an Error occurs. Use option_env! to read the generated environment variables.

Trait Implementations§

source§

impl Clone for Git

source§

fn clone(&self) -> Git

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Git

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Git

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Git

§

impl Send for Git

§

impl Sync for Git

§

impl Unpin for Git

§

impl UnwindSafe for Git

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere
T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.