pub struct Hook {Show 18 fields
pub id: String,
pub name: Option<String>,
pub entry: String,
pub language: String,
pub files: Option<String>,
pub exclude: Option<String>,
pub types: Vec<String>,
pub exclude_types: Vec<String>,
pub additional_dependencies: Vec<String>,
pub args: Vec<String>,
pub always_run: bool,
pub fail_fast: bool,
pub pass_filenames: bool,
pub stages: Vec<Stage>,
pub verbose: bool,
pub minimum_pre_commit_version: Option<String>,
pub depends_on: Vec<String>,
pub concurrent: bool,
}Expand description
Enhanced Hook structure with runtime capabilities
Fields§
§id: StringUnique identifier for the hook
name: Option<String>Human-readable name (optional)
entry: StringCommand to execute
language: StringProgramming language environment
files: Option<String>File patterns to include (raw string for serialization)
exclude: Option<String>File patterns to exclude (raw string for serialization)
types: Vec<String>File types to include
exclude_types: Vec<String>File types to exclude
additional_dependencies: Vec<String>Additional dependencies to install
args: Vec<String>Additional arguments to pass to the hook
always_run: boolWhether to always run this hook, even if no files match
fail_fast: boolWhether to fail fast on first error
pass_filenames: boolWhether to pass filenames to the hook
stages: Vec<Stage>Stages where this hook should run
verbose: boolWhether to show verbose output
minimum_pre_commit_version: Option<String>Minimum version required
depends_on: Vec<String>Hook IDs that this hook depends on (must run before this hook)
concurrent: boolWhether this hook can run concurrently with others (default: true)
Implementations§
Source§impl Hook
impl Hook
Sourcepub fn new(
id: impl Into<String>,
entry: impl Into<String>,
language: impl Into<String>,
) -> Self
pub fn new( id: impl Into<String>, entry: impl Into<String>, language: impl Into<String>, ) -> Self
Create a new hook with required fields
pub fn with_files(self, files: impl Into<String>) -> Self
pub fn with_exclude(self, exclude: impl Into<String>) -> Self
pub fn with_types(self, types: Vec<String>) -> Self
pub fn with_args(self, args: Vec<String>) -> Self
pub fn with_stages(self, stages: Vec<Stage>) -> Self
pub fn always_run(self, always_run: bool) -> Self
pub fn fail_fast(self, fail_fast: bool) -> Self
pub fn pass_filenames(self, pass_filenames: bool) -> Self
pub fn with_verbose(self, verbose: bool) -> Self
pub fn with_exclude_types(self, exclude_types: Vec<String>) -> Self
pub fn with_additional_dependencies( self, additional_dependencies: Vec<String>, ) -> Self
pub fn with_depends_on(self, depends_on: Vec<String>) -> Self
pub fn with_concurrent(self, concurrent: bool) -> Self
Sourcepub fn file_filter(&self) -> Result<FileFilter>
pub fn file_filter(&self) -> Result<FileFilter>
Get a file filter for this hook
Sourcepub fn runs_for_stage(&self, stage: &Stage) -> bool
pub fn runs_for_stage(&self, stage: &Stage) -> bool
Check if this hook should run for the given stage
Sourcepub fn command(&self) -> Vec<String>
pub fn command(&self) -> Vec<String>
Get the full command to execute For optimal performance, consider using command_cow() for zero-copy operations
Sourcepub fn command_cow(&self) -> Vec<Cow<'_, str>>
pub fn command_cow(&self) -> Vec<Cow<'_, str>>
Get the full command to execute using zero-copy operations with Cow
Sourcepub fn command_arena<'arena>(
&self,
arena: &'arena Bump,
) -> &'arena [&'arena str]
pub fn command_arena<'arena>( &self, arena: &'arena Bump, ) -> &'arena [&'arena str]
Get the full command to execute using arena allocation for better performance This method avoids string clones by allocating command strings in the provided arena
Sourcepub fn from_config(config_hook: &Hook, _repo_url: &str) -> Result<Self>
pub fn from_config(config_hook: &Hook, _repo_url: &str) -> Result<Self>
Create a Hook from configuration
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Hook
impl<'de> Deserialize<'de> for Hook
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Hook
Auto Trait Implementations§
impl Freeze for Hook
impl RefUnwindSafe for Hook
impl Send for Hook
impl Sync for Hook
impl Unpin for Hook
impl UnwindSafe for Hook
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)