Add the PreCommit hook struct.

This commit is contained in:
Bauke 2022-10-28 13:58:36 +02:00
parent 1eecfa7146
commit 7a543409ba
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
2 changed files with 25 additions and 0 deletions

View File

@ -9,10 +9,12 @@ use {
mod exit_action;
mod general;
mod pre_commit;
mod task;
pub use exit_action::*;
pub use general::*;
pub use pre_commit::*;
pub use task::*;
/// The main Hooked configuration struct.
@ -21,6 +23,9 @@ pub use task::*;
pub struct Config {
/// General Hooked configuration.
pub general: General,
/// Pre-commit hooks.
pub pre_commit: Vec<PreCommit>,
}
impl Config {

View File

@ -0,0 +1,20 @@
//! Pre-commit hook definitions.
use serde::{Deserialize, Serialize};
use crate::{ExitAction, Task};
/// A pre-commit hook.
#[derive(Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct PreCommit {
/// Display name for this hook.
pub name: Option<String>,
/// What to do when the hook exits with a non-zero status code.
pub on_failure: ExitAction,
/// Task to perform when this hook is called.
#[serde(flatten)]
pub task: Task,
}