Skip to main content

GitSandbox

Struct GitSandbox 

Source
pub struct GitSandbox { /* private fields */ }
Expand description

A throwaway git repository: owns its TempDir, initialised on branch main with a deterministic identity (see configure_identity).

Scenario-building goes through the raw git escape hatch plus the convenience methods — the sandbox deliberately does not depend on the typed wrapper crates, so it can be a dev-dependency of any of them.

Implementations§

Source§

impl GitSandbox

Source

pub fn init(tag: &str) -> Self

Create and initialise a repository (git init -b main — git ≥ 2.28, comfortably below the wrappers’ documented floor).

--template= (empty) makes the new repo skip any init template, so a host-global init.templateDir cannot seed hooks into .git/hooks — the version-portable complement to the config isolation in command.

Source

pub fn path(&self) -> &Path

The repository’s working-tree path.

Source

pub fn git(&self, args: &[&str])

Run git <args> in the repository, panicking on failure.

Source

pub fn write(&self, path: &str, content: &str)

Write content to the repo-relative path (creating parent dirs).

Source

pub fn add_all(&self)

Stage everything (git add -A).

Source

pub fn commit(&self, message: &str)

Commit the staged changes (git commit -qm <message>).

Source

pub fn commit_file(&self, path: &str, content: &str, message: &str)

Write + stage + commit one file — the everyday scenario step.

Source

pub fn branch(&self, name: &str)

Create a branch at HEAD without switching (git branch <name>).

Source

pub fn checkout(&self, name: &str)

Switch to a branch (git checkout <name>).

Source

pub fn rev_parse(&self, rev: &str) -> String

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

Auto Trait Implementations§

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.