Struct branchless::testing::GitWrapper
source · [−]pub struct GitWrapper { /* private fields */ }
Expand description
Wrapper around a Git
instance which cleans up the repository once dropped.
Implementations
sourceimpl GitWrapper
impl GitWrapper
sourcepub fn duplicate_repo(&self) -> Result<Self>
pub fn duplicate_repo(&self) -> Result<Self>
Make a copy of the repo on disk. This can be used to reuse testing
setup. This is not the same as running git clone
; it’s used to save
initialization time as part of testing optimization.
The copied repo will be deleted once the returned value has been dropped.
Methods from Deref<Target = Git>
sourcepub fn preprocess_output(&self, stdout: String) -> Result<String>
pub fn preprocess_output(&self, stdout: String) -> Result<String>
Replace dynamic strings in the output, for testing purposes.
sourcepub fn get_path_for_env(&self) -> OsString
pub fn get_path_for_env(&self) -> OsString
Get the PATH
environment variable to use for testing.
sourcepub fn get_base_env(&self, time: isize) -> Vec<(OsString, OsString)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn get_base_env(&self, time: isize) -> Vec<(OsString, OsString)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Get the environment variables needed to run git in the test environment.
sourcepub fn run_with_options<S: AsRef<str> + Debug>(
&self,
args: &[S],
options: &GitRunOptions
) -> Result<(String, String)>
pub fn run_with_options<S: AsRef<str> + Debug>(
&self,
args: &[S],
options: &GitRunOptions
) -> Result<(String, String)>
Run a Git command.
sourcepub fn run<S: AsRef<str> + Debug>(&self, args: &[S]) -> Result<(String, String)>
pub fn run<S: AsRef<str> + Debug>(&self, args: &[S]) -> Result<(String, String)>
Run a Git command.
sourcepub fn init_repo_with_options(&self, options: &GitInitOptions) -> Result<()>
pub fn init_repo_with_options(&self, options: &GitInitOptions) -> Result<()>
Set up a Git repo in the directory and initialize git-branchless to work with it.
sourcepub fn init_repo(&self) -> Result<()>
pub fn init_repo(&self) -> Result<()>
Set up a Git repo in the directory and initialize git-branchless to work with it.
sourcepub fn clone_repo_into(
&self,
target: &Git,
additional_args: &[&str]
) -> Result<()>
pub fn clone_repo_into(
&self,
target: &Git,
additional_args: &[&str]
) -> Result<()>
Clone this repository into the target
repository (which must not have
been initialized).
sourcepub fn write_file(&self, name: &str, contents: &str) -> Result<()>
pub fn write_file(&self, name: &str, contents: &str) -> Result<()>
Write the provided contents to the provided file in the repository root.
sourcepub fn delete_file(&self, name: &str) -> Result<()>
pub fn delete_file(&self, name: &str) -> Result<()>
Delete the provided file in the repository root.
sourcepub fn set_file_permissions(
&self,
name: &str,
permissions: Permissions
) -> Result<()>
pub fn set_file_permissions(
&self,
name: &str,
permissions: Permissions
) -> Result<()>
Delete the provided file in the repository root.
sourcepub fn commit_file_with_contents(
&self,
name: &str,
time: isize,
contents: &str
) -> Result<NonZeroOid>
pub fn commit_file_with_contents(
&self,
name: &str,
time: isize,
contents: &str
) -> Result<NonZeroOid>
Commit a file with default contents. The time
argument is used to set
the commit timestamp, which is factored into the commit hash.
sourcepub fn commit_file(&self, name: &str, time: isize) -> Result<NonZeroOid>
pub fn commit_file(&self, name: &str, time: isize) -> Result<NonZeroOid>
Commit a file with default contents. The time
argument is used to set
the commit timestamp, which is factored into the commit hash.
sourcepub fn detach_head(&self) -> Result<()>
pub fn detach_head(&self) -> Result<()>
Detach HEAD. This is useful to call to make sure that no branch is checked out, and therefore that future commit operations don’t move any branches.
sourcepub fn get_version(&self) -> Result<GitVersion>
pub fn get_version(&self) -> Result<GitVersion>
Get the version of the Git executable.
sourcepub fn get_git_run_info(&self) -> GitRunInfo
pub fn get_git_run_info(&self) -> GitRunInfo
Get the GitRunInfo
to use for this repository.
sourcepub fn supports_reference_transactions(&self) -> Result<bool>
pub fn supports_reference_transactions(&self) -> Result<bool>
Determine if the Git executable supports the reference-transaction
hook.
Determine if the --committer-date-is-author-date
option to git rebase -i
is respected.
This affects whether we can rely on the timestamps being preserved
during a rebase when branchless.restack.preserveTimestamps
is set.
sourcepub fn supports_log_exclude_decoration(&self) -> Result<bool>
pub fn supports_log_exclude_decoration(&self) -> Result<bool>
The log.excludeDecoration
configuration option was introduced in Git
v2.27.
sourcepub fn resolve_file(&self, name: &str, contents: &str) -> Result<()>
pub fn resolve_file(&self, name: &str, contents: &str) -> Result<()>
Resolve a file during a merge or rebase conflict with the provided contents.
sourcepub fn clear_event_log(&self) -> Result<()>
pub fn clear_event_log(&self) -> Result<()>
Clear the event log on disk. Currently-existing commits will not have been observed by the new event log (once it’s created by another command).
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for GitWrapper
impl Send for GitWrapper
impl Sync for GitWrapper
impl Unpin for GitWrapper
impl UnwindSafe for GitWrapper
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<D> OwoColorize for D
impl<D> OwoColorize for D
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn black(&'a self) -> FgColorDisplay<'a, Black, Self>
fn black(&'a self) -> FgColorDisplay<'a, Black, Self>
fn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
fn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
fn red(&'a self) -> FgColorDisplay<'a, Red, Self>
fn red(&'a self) -> FgColorDisplay<'a, Red, Self>
fn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
fn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
fn green(&'a self) -> FgColorDisplay<'a, Green, Self>
fn green(&'a self) -> FgColorDisplay<'a, Green, Self>
fn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
fn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
fn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn white(&'a self) -> FgColorDisplay<'a, White, Self>
fn white(&'a self) -> FgColorDisplay<'a, White, Self>
fn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
fn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
fn default_color(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color(&'a self) -> FgColorDisplay<'a, Default, Self>
fn on_default_color(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color(&'a self) -> BgColorDisplay<'a, Default, Self>
fn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn bold(&'a self) -> BoldDisplay<'a, Self>
fn bold(&'a self) -> BoldDisplay<'a, Self>
fn dimmed(&'a self) -> DimDisplay<'a, Self>
fn dimmed(&'a self) -> DimDisplay<'a, Self>
fn italic(&'a self) -> ItalicDisplay<'a, Self>
fn italic(&'a self) -> ItalicDisplay<'a, Self>
fn underline(&'a self) -> UnderlineDisplay<'a, Self>
fn underline(&'a self) -> UnderlineDisplay<'a, Self>
fn blink(&'a self) -> BlinkDisplay<'a, Self>
fn blink(&'a self) -> BlinkDisplay<'a, Self>
fn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
fn reversed(&'a self) -> ReversedDisplay<'a, Self>
fn reversed(&'a self) -> ReversedDisplay<'a, Self>
fn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read morefn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more