Struct branchless::testing::Git
source · [−]Expand description
Wrapper around the Git executable, for testing.
Fields
repo_path: PathBuf
The path to the repository on disk. The directory itself must exist,
although it might not have a .git
folder in it. (Use Git::init_repo
to initialize it.)
path_to_git: PathBuf
The path to the Git executable on disk. This is important since we test against multiple Git versions.
Implementations
sourceimpl Git
impl Git
sourcepub fn new(repo_path: PathBuf, git_run_info: GitRunInfo) -> Self
pub fn new(repo_path: PathBuf, git_run_info: GitRunInfo) -> Self
Constructor.
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 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.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Git
impl Send for Git
impl Sync for Git
impl Unpin for Git
impl UnwindSafe for Git
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
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>(&'a self) -> FgColorDisplay<'a, C, Self> where
C: Color,
fn fg<C>(&'a self) -> FgColorDisplay<'a, C, Self> where
C: Color,
Set the foreground color generically Read more
fn bg<C>(&'a self) -> BgColorDisplay<'a, C, Self> where
C: Color,
fn bg<C>(&'a self) -> BgColorDisplay<'a, C, Self> where
C: Color,
Set the background color generically. Read more
fn black(&'a self) -> FgColorDisplay<'a, Black, Self>
fn black(&'a self) -> FgColorDisplay<'a, Black, Self>
Change the foreground color to black
fn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
fn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
Change the foreground color to black
fn red(&'a self) -> FgColorDisplay<'a, Red, Self>
fn red(&'a self) -> FgColorDisplay<'a, Red, Self>
Change the foreground color to red
fn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
fn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
Change the foreground color to red
fn green(&'a self) -> FgColorDisplay<'a, Green, Self>
fn green(&'a self) -> FgColorDisplay<'a, Green, Self>
Change the foreground color to green
fn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
fn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
Change the foreground color to green
fn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
Change the foreground color to yellow
fn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
Change the foreground color to yellow
fn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
Change the foreground color to blue
fn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
Change the foreground color to blue
fn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
Change the foreground color to magenta
fn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
Change the foreground color to magenta
fn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
Change the foreground color to purple
fn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
Change the foreground color to purple
fn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
Change the foreground color to cyan
fn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
Change the foreground color to cyan
fn white(&'a self) -> FgColorDisplay<'a, White, Self>
fn white(&'a self) -> FgColorDisplay<'a, White, Self>
Change the foreground color to white
fn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
fn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
Change the foreground color to white
fn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
Change the foreground color to bright black
fn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
Change the foreground color to bright black
fn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
Change the foreground color to bright red
fn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
Change the foreground color to bright red
fn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
Change the foreground color to bright green
fn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
Change the foreground color to bright green
fn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
Change the foreground color to bright yellow
fn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
Change the foreground color to bright yellow
fn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
Change the foreground color to bright blue
fn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
Change the foreground color to bright blue
fn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright magenta
fn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright magenta
fn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright purple
fn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright purple
fn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
Change the foreground color to bright cyan
fn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
Change the foreground color to bright cyan
fn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
Change the foreground color to bright white
fn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
Change the foreground color to bright white
fn bold(&'a self) -> BoldDisplay<'a, Self>
fn bold(&'a self) -> BoldDisplay<'a, Self>
Make the text bold
fn dimmed(&'a self) -> DimDisplay<'a, Self>
fn dimmed(&'a self) -> DimDisplay<'a, Self>
Make the text dim
fn italic(&'a self) -> ItalicDisplay<'a, Self>
fn italic(&'a self) -> ItalicDisplay<'a, Self>
Make the text italicized
fn underline(&'a self) -> UnderlineDisplay<'a, Self>
fn underline(&'a self) -> UnderlineDisplay<'a, Self>
Make the text italicized
fn blink(&'a self) -> BlinkDisplay<'a, Self>
fn blink(&'a self) -> BlinkDisplay<'a, Self>
Make the text blink
fn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
Make the text blink (but fast!)
fn reversed(&'a self) -> ReversedDisplay<'a, Self>
fn reversed(&'a self) -> ReversedDisplay<'a, Self>
Swap the foreground and background colors
Hide the text
fn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
Cross out the text
fn color<Color>(&'a self, color: Color) -> FgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
fn color<Color>(&'a self, color: Color) -> FgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
Set the foreground color at runtime. Only use if you do not know which color will be used at
compile-time. If the color is constant, use either OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read more
fn on_color<Color>(&'a self, color: Color) -> BgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
fn on_color<Color>(&'a self, color: Color) -> BgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
Set the background color at runtime. Only use if you do not know what color to use at
compile-time. If the color is constant, use either OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more
fn truecolor(&'a self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'a, Rgb, Self>
fn truecolor(&'a self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'a, Rgb, Self>
Sets the foreground color to an RGB value.
fn on_truecolor(
&'a self,
r: u8,
g: u8,
b: u8
) -> BgDynColorDisplay<'a, Rgb, Self>
fn on_truecolor(
&'a self,
r: u8,
g: u8,
b: u8
) -> BgDynColorDisplay<'a, Rgb, Self>
Sets the background color to an RGB value.
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more