Skip to main content

Git

Struct Git 

Source
pub struct Git<R: ProcessRunner = JobRunner> { /* private fields */ }
Expand description

The real Git client. Generic over the ProcessRunner so tests can inject a fake process executor; Git::new() uses the real job-backed runner.

Implementations§

Source§

impl Git<JobRunner>

Source

pub fn new() -> Self

Create a client driving the real job-backed runner.

Source§

impl<R: ProcessRunner> Git<R>

Source

pub fn with_runner(runner: R) -> Self

Create a client driving runner — inject a fake in tests.

Source

pub fn default_timeout(self, timeout: Duration) -> Self

Apply a default timeout to every command this client builds.

Trait Implementations§

Source§

impl Default for Git<JobRunner>

Source§

fn default() -> Self

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

impl<R: ProcessRunner> GitApi for Git<R>

Source§

fn run<'life0, 'life1, 'async_trait>( &'life0 self, args: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Run git <args> in the current directory, returning trimmed stdout (throws on a non-zero exit). A raw escape hatch for unmodelled commands.
Source§

fn run_raw<'life0, 'life1, 'async_trait>( &'life0 self, args: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<ProcessResult<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Like GitApi::run but never errors on a non-zero exit — returns the captured ProcessResult.
Source§

fn version<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Installed Git version (git --version).
Source§

fn status<'life0, 'life1, 'async_trait>( &'life0 self, dir: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<StatusEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Working-tree status (git status --porcelain=v1 -z).
Source§

fn current_branch<'life0, 'life1, 'async_trait>( &'life0 self, dir: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Current branch name (git rev-parse --abbrev-ref HEAD).
Source§

fn branches<'life0, 'life1, 'async_trait>( &'life0 self, dir: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<Branch>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Local branches, current one flagged (git branch).
Source§

fn log<'life0, 'life1, 'async_trait>( &'life0 self, dir: &'life1 Path, max: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Commit>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Latest max commits, newest first (git log).
Source§

fn rev_parse<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, dir: &'life1 Path, rev: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Resolve a revision to a full hash (git rev-parse <rev>).
Source§

fn init<'life0, 'life1, 'async_trait>( &'life0 self, dir: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Initialise a repository (git init).
Source§

fn add<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, dir: &'life1 Path, paths: &'life2 [PathBuf], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Stage paths (git add -- <paths>).
Source§

fn commit<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, dir: &'life1 Path, message: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Commit staged changes (git commit -m).
Source§

fn create_branch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, dir: &'life1 Path, name: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create a branch without switching to it (git branch <name>).
Source§

fn checkout<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, dir: &'life1 Path, reference: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Switch to a branch or revision (git checkout <reference>).
Source§

fn diff_is_empty<'life0, 'life1, 'async_trait>( &'life0 self, dir: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Whether the working tree has no unstaged changes (git diff --quiet).

Auto Trait Implementations§

§

impl<R> Freeze for Git<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Git<R>
where R: RefUnwindSafe,

§

impl<R> Send for Git<R>

§

impl<R> Sync for Git<R>

§

impl<R> Unpin for Git<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for Git<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for Git<R>
where R: UnwindSafe,

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.