pub struct GitContext {
pub commit: Option<String>,
pub branch: Option<String>,
pub tag: Option<String>,
pub dirty: Option<bool>,
}Expand description
Git context at the time of publishing.
Captures the current git state, including commit hash, branch, tag, and whether the working directory is dirty.
§Example
ⓘ
use shipper::types::GitContext;
let ctx = GitContext {
commit: Some("abc123def".to_string()),
branch: Some("main".to_string()),
tag: Some("v1.0.0".to_string()),
dirty: Some(false),
};Fields§
§commit: Option<String>§branch: Option<String>§tag: Option<String>§dirty: Option<bool>Implementations§
Source§impl GitContext
impl GitContext
Sourcepub fn has_commit(&self) -> bool
pub fn has_commit(&self) -> bool
Whether the context has commit information.
Sourcepub fn is_dirty(&self) -> bool
pub fn is_dirty(&self) -> bool
Whether the working tree is dirty.
When dirty is None, this defaults to true (treat unknown as dirty) to
preserve the safe-by-default semantics of the original shipper-git crate.
Sourcepub fn short_commit(&self) -> Option<&str>
pub fn short_commit(&self) -> Option<&str>
Get a short commit hash (first 7 bytes).
Returns None if the context has no commit. The original shipper-git
implementation sliced by byte index assuming ASCII hex; we preserve the
same behavior here (input shorter than 7 bytes is returned verbatim).
Trait Implementations§
Source§impl Clone for GitContext
impl Clone for GitContext
Source§fn clone(&self) -> GitContext
fn clone(&self) -> GitContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GitContext
impl Debug for GitContext
Source§impl Default for GitContext
impl Default for GitContext
Source§fn default() -> GitContext
fn default() -> GitContext
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for GitContext
impl<'de> Deserialize<'de> for GitContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GitContext
impl RefUnwindSafe for GitContext
impl Send for GitContext
impl Sync for GitContext
impl Unpin for GitContext
impl UnsafeUnpin for GitContext
impl UnwindSafe for GitContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more