Struct git_nomad::git_binary::GitBinary

source ·
pub struct GitBinary<'name> {
    pub verbosity: Option<Verbosity>,
    name: Cow<'name, str>,
    git_dir: String,
}
Expand description

Implements repository manipulations by delegating to some ambient git binary that exists somewhere on the system.

Fields§

§verbosity: Option<Verbosity>

Used to actually execute commands while reporting progress to the user.

§name: Cow<'name, str>

The name of the git binary to use. Implemented on top of Command::new, so non-absolute paths are looked up against $PATH.

§git_dir: String

The absolute path to the .git directory of the repository.

Implementations§

source§

impl<'name> GitBinary<'name>

source

pub fn new( renderer: &mut impl Renderer, verbosity: Option<Verbosity>, name: Cow<'name, str>, cwd: &Path, ) -> Result<Self>

Create a new GitBinary by finding the .git dir relative to cwd, which implements the usual git rules of searching ancestor directories.

source§

impl GitBinary<'_>

source

pub fn command(&self) -> Command

Invoke a git sub-command with an explicit --git-dir to make it independent of the working directory it is invoked from.

source

pub fn get_config( &self, renderer: &mut impl Renderer, key: &str, ) -> Result<Option<String>>

Wraps git config to read a single namespaced value.

source

fn get_config_with_env( &self, renderer: &mut impl Renderer, key: &str, vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>, ) -> Result<Option<String>>

source

fn fetch_refspecs<Description, RefSpec>( &self, renderer: &mut impl Renderer, description: Description, remote: &Remote<'_>, refspecs: &[RefSpec], ) -> Result<()>
where Description: AsRef<str>, RefSpec: AsRef<OsStr>,

Wraps git fetch to fetch refs from a given remote into the local repository.

§Panics

If refspecs is empty, which means git will use the user configured default behaviour which is definitely not what we want.

source

fn push_refspecs<Description, RefSpec>( &self, renderer: &mut impl Renderer, description: Description, remote: &Remote<'_>, refspecs: &[RefSpec], ) -> Result<()>
where Description: AsRef<str>, RefSpec: AsRef<OsStr>,

Wraps git push to push refs from the local repository into the given remote.

§Panics

If refspecs is empty, which means git will use the user configured default behaviour which is definitely not what we want.

source

pub fn list_refs<Description>( &self, renderer: &mut impl Renderer, description: Description, ) -> Result<Vec<GitRef>>
where Description: AsRef<str>,

List all the non-HEAD refs in the repository as GitRefs.

source

fn list_remote_refs<Description, RefSpec>( &self, renderer: &mut impl Renderer, description: Description, remote: &Remote<'_>, refspecs: &[RefSpec], ) -> Result<Vec<GitRef>>
where Description: AsRef<str>, RefSpec: AsRef<OsStr>,

Wraps git ls-remote to query a remote for all refs that match the given refspecs.

§Panics

If refspecs is empty, which means git will list all refs, which is never what we want.

source

fn delete_ref<Description>( &self, renderer: &mut impl Renderer, description: Description, git_ref: &GitRef, ) -> Result<()>
where Description: AsRef<str>,

Delete a ref from the repository.

Note that deleting refs on a remote is done via GitBinary::push_refspecs.

source

pub fn current_branch( &self, renderer: &mut impl Renderer, ) -> Result<Branch<'static>>

Get the current branch, which may fail if the work tree is in a detached HEAD state.

source

pub fn is_output_allowed(&self) -> bool

Should higher level commands be producing output, or has the user requested quiet mode?

source

pub fn snapshot<'a>( &self, renderer: &mut impl Renderer, user: &'a User<'_>, ) -> Result<Snapshot<'a, GitRef>>

Build a point in time snapshot for all refs that nomad cares about from the state in the local git clone.

source

pub fn fetch_nomad_refs( &self, renderer: &mut impl Renderer, user: &User<'_>, remote: &Remote<'_>, ) -> Result<()>

Fetch all nomad managed refs from a given remote.

source

pub fn list_nomad_refs( &self, renderer: &mut impl Renderer, user: &User<'_>, remote: &Remote<'_>, ) -> Result<impl Iterator<Item = NomadRef<'_, GitRef>>>

List all nomad managed refs from a given remote.

Separated from Self::fetch_nomad_refs because not all callers want to pay the overhead of actually listing the fetched refs.

source

pub fn push_nomad_refs( &self, renderer: &mut impl Renderer, user: &User<'_>, host: &Host<'_>, remote: &Remote<'_>, ) -> Result<()>

Push local branches to nomad managed refs in the remote.

source

pub fn prune_nomad_refs<'a>( &self, renderer: &mut impl Renderer, remote: &Remote<'_>, prune: impl Iterator<Item = PruneFrom<'a, GitRef>>, ) -> Result<()>

Delete the given nomad managed refs.

Trait Implementations§

source§

impl<'name> PartialEq for GitBinary<'name>

source§

fn eq(&self, other: &GitBinary<'name>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'name> Eq for GitBinary<'name>

source§

impl<'name> StructuralPartialEq for GitBinary<'name>

Auto Trait Implementations§

§

impl<'name> Freeze for GitBinary<'name>

§

impl<'name> RefUnwindSafe for GitBinary<'name>

§

impl<'name> Send for GitBinary<'name>

§

impl<'name> Sync for GitBinary<'name>

§

impl<'name> Unpin for GitBinary<'name>

§

impl<'name> UnwindSafe for GitBinary<'name>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

source§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.