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: StringThe absolute path to the .git directory of the repository.
Implementations§
source§impl GitBinary<'_>
impl GitBinary<'_>
sourcepub fn command(&self) -> Command
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.
sourcepub fn get_config(
&self,
renderer: &mut impl Renderer,
key: &str,
) -> Result<Option<String>>
pub fn get_config( &self, renderer: &mut impl Renderer, key: &str, ) -> Result<Option<String>>
Wraps git config to read a single namespaced value.
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>>
sourcefn fetch_refspecs<Description, RefSpec>(
&self,
renderer: &mut impl Renderer,
description: Description,
remote: &Remote<'_>,
refspecs: &[RefSpec],
) -> Result<()>
fn fetch_refspecs<Description, RefSpec>( &self, renderer: &mut impl Renderer, description: Description, remote: &Remote<'_>, refspecs: &[RefSpec], ) -> Result<()>
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.
sourcefn push_refspecs<Description, RefSpec>(
&self,
renderer: &mut impl Renderer,
description: Description,
remote: &Remote<'_>,
refspecs: &[RefSpec],
) -> Result<()>
fn push_refspecs<Description, RefSpec>( &self, renderer: &mut impl Renderer, description: Description, remote: &Remote<'_>, refspecs: &[RefSpec], ) -> Result<()>
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.
sourcepub fn list_refs<Description>(
&self,
renderer: &mut impl Renderer,
description: Description,
) -> Result<Vec<GitRef>>
pub fn list_refs<Description>( &self, renderer: &mut impl Renderer, description: Description, ) -> Result<Vec<GitRef>>
List all the non-HEAD refs in the repository as GitRefs.
sourcefn list_remote_refs<Description, RefSpec>(
&self,
renderer: &mut impl Renderer,
description: Description,
remote: &Remote<'_>,
refspecs: &[RefSpec],
) -> Result<Vec<GitRef>>
fn list_remote_refs<Description, RefSpec>( &self, renderer: &mut impl Renderer, description: Description, remote: &Remote<'_>, refspecs: &[RefSpec], ) -> Result<Vec<GitRef>>
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.
sourcefn delete_ref<Description>(
&self,
renderer: &mut impl Renderer,
description: Description,
git_ref: &GitRef,
) -> Result<()>
fn delete_ref<Description>( &self, renderer: &mut impl Renderer, description: Description, git_ref: &GitRef, ) -> Result<()>
Delete a ref from the repository.
Note that deleting refs on a remote is done via GitBinary::push_refspecs.
sourcepub fn current_branch(
&self,
renderer: &mut impl Renderer,
) -> Result<Branch<'static>>
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.
sourcepub fn is_output_allowed(&self) -> bool
pub fn is_output_allowed(&self) -> bool
Should higher level commands be producing output, or has the user requested quiet mode?
sourcepub fn snapshot<'a>(
&self,
renderer: &mut impl Renderer,
user: &'a User<'_>,
) -> Result<Snapshot<'a, GitRef>>
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.
sourcepub fn fetch_nomad_refs(
&self,
renderer: &mut impl Renderer,
user: &User<'_>,
remote: &Remote<'_>,
) -> Result<()>
pub fn fetch_nomad_refs( &self, renderer: &mut impl Renderer, user: &User<'_>, remote: &Remote<'_>, ) -> Result<()>
Fetch all nomad managed refs from a given remote.
sourcepub fn list_nomad_refs(
&self,
renderer: &mut impl Renderer,
user: &User<'_>,
remote: &Remote<'_>,
) -> Result<impl Iterator<Item = NomadRef<'_, GitRef>>>
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.