Hook

Struct Hook 

Source
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: String

Unique identifier for the hook

§name: Option<String>

Human-readable name (optional)

§entry: String

Command to execute

§language: String

Programming 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: bool

Whether to always run this hook, even if no files match

§fail_fast: bool

Whether to fail fast on first error

§pass_filenames: bool

Whether to pass filenames to the hook

§stages: Vec<Stage>

Stages where this hook should run

§verbose: bool

Whether 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: bool

Whether this hook can run concurrently with others (default: true)

Implementations§

Source§

impl Hook

Source

pub fn new( id: impl Into<String>, entry: impl Into<String>, language: impl Into<String>, ) -> Self

Create a new hook with required fields

Source

pub fn with_name(self, name: impl Into<String>) -> Self

Builder pattern methods

Source

pub fn with_files(self, files: impl Into<String>) -> Self

Source

pub fn with_exclude(self, exclude: impl Into<String>) -> Self

Source

pub fn with_types(self, types: Vec<String>) -> Self

Source

pub fn with_args(self, args: Vec<String>) -> Self

Source

pub fn with_stages(self, stages: Vec<Stage>) -> Self

Source

pub fn always_run(self, always_run: bool) -> Self

Source

pub fn fail_fast(self, fail_fast: bool) -> Self

Source

pub fn pass_filenames(self, pass_filenames: bool) -> Self

Source

pub fn with_verbose(self, verbose: bool) -> Self

Source

pub fn with_exclude_types(self, exclude_types: Vec<String>) -> Self

Source

pub fn with_additional_dependencies( self, additional_dependencies: Vec<String>, ) -> Self

Source

pub fn with_depends_on(self, depends_on: Vec<String>) -> Self

Source

pub fn with_concurrent(self, concurrent: bool) -> Self

Source

pub fn validate(&self) -> Result<()>

Validate the hook configuration

Source

pub fn file_filter(&self) -> Result<FileFilter>

Get a file filter for this hook

Source

pub fn runs_for_stage(&self, stage: &Stage) -> bool

Check if this hook should run for the given stage

Source

pub fn command(&self) -> Vec<String>

Get the full command to execute For optimal performance, consider using command_cow() for zero-copy operations

Source

pub fn command_cow(&self) -> Vec<Cow<'_, str>>

Get the full command to execute using zero-copy operations with Cow This method eliminates unnecessary string clones by borrowing string slices when possible

Source

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

Source

pub fn from_config(config_hook: &Hook, _repo_url: &str) -> Result<Self>

Create a Hook from configuration

Trait Implementations§

Source§

impl Clone for Hook

Source§

fn clone(&self) -> Hook

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Hook

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Hook

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Hook

Source§

fn eq(&self, other: &Hook) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Hook

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,