Struct git_checks::checks::Formatting
source · pub struct Formatting { /* private fields */ }
Expand description
Run a formatter in the repository to check commits for formatting.
The formatter is passed a single argument: the path to the file which should be checked.
The formatter is expected to exit with success whether the path passed to it has a valid format in it or not. A failure exit status is considered a failure of the formatter itself. If any changes (including untracked files) are left inside of the worktree, it is considered to have failed the checks.
The formatter is run with its current working directory being the top-level of the work tree,
but not the proper GIT_
context. This is because the setup for the workarea is not completely
isolated and git
commands may not behave as expected. The worktree it is working from is only
guaranteed to have the files which have changed in the commit being checked on disk, so
additional files which should be available for the command to run must be specified with
Formatting::add_config_files
.
Implementations§
source§impl Formatting
impl Formatting
sourcepub fn new<K, F>(kind: K, formatter: F) -> Selfwhere
K: ToString,
F: AsRef<Path>,
pub fn new<K, F>(kind: K, formatter: F) -> Selfwhere
K: ToString,
F: AsRef<Path>,
Create a new formatting check.
sourcepub fn named<N>(&mut self, name: N) -> &mut Selfwhere
N: ToString,
pub fn named<N>(&mut self, name: N) -> &mut Selfwhere
N: ToString,
Set the name of the formatter.
sourcepub fn add_config_files<I, F>(&mut self, files: I) -> &mut Selfwhere
I: IntoIterator<Item = F>,
F: ToString,
pub fn add_config_files<I, F>(&mut self, files: I) -> &mut Selfwhere
I: IntoIterator<Item = F>,
F: ToString,
Add configuration files within the repository which should be checked out.
sourcepub fn with_fix_message<F>(&mut self, fix_message: F) -> &mut Selfwhere
F: ToString,
pub fn with_fix_message<F>(&mut self, fix_message: F) -> &mut Selfwhere
F: ToString,
Add a message for how to fix issues with this formatter.
sourcepub fn with_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn with_timeout(&mut self, timeout: Duration) -> &mut Self
Add a timeout to the formatter.
Trait Implementations§
source§impl Clone for Formatting
impl Clone for Formatting
source§fn clone(&self) -> Formatting
fn clone(&self) -> Formatting
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more