2022-10-28 11:58:36 +00:00
|
|
|
//! Pre-commit hook definitions.
|
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2024-01-17 17:43:17 +00:00
|
|
|
use crate::{ExitAction, NoiseLevel, Task};
|
2022-10-28 11:58:36 +00:00
|
|
|
|
|
|
|
/// A pre-commit hook.
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
|
|
#[serde(deny_unknown_fields)]
|
|
|
|
pub struct PreCommit {
|
|
|
|
/// Display name for this hook.
|
|
|
|
pub name: Option<String>,
|
|
|
|
|
2024-01-17 17:43:17 +00:00
|
|
|
/// The noise level this task should output with.
|
|
|
|
#[serde(default)]
|
|
|
|
pub noise_level: NoiseLevel,
|
|
|
|
|
2022-10-28 11:58:36 +00:00
|
|
|
/// What to do when the hook exits with a non-zero status code.
|
2022-10-28 12:08:27 +00:00
|
|
|
#[serde(default)]
|
2022-10-28 11:58:36 +00:00
|
|
|
pub on_failure: ExitAction,
|
|
|
|
|
2022-11-27 16:29:44 +00:00
|
|
|
/// List of globs to check against staged files.
|
|
|
|
#[serde(default)]
|
|
|
|
pub staged: Vec<String>,
|
|
|
|
|
2022-10-28 11:58:36 +00:00
|
|
|
/// Task to perform when this hook is called.
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub task: Task,
|
|
|
|
}
|