Make noise_level optional for hooks.

This commit is contained in:
Bauke 2024-01-18 12:27:27 +01:00
parent 260bcb7ca5
commit df397b2cda
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
6 changed files with 8 additions and 9 deletions

View File

@ -12,8 +12,7 @@ pub struct PreCommit {
pub name: Option<String>, pub name: Option<String>,
/// The noise level this task should output with. /// The noise level this task should output with.
#[serde(default)] pub noise_level: Option<NoiseLevel>,
pub noise_level: NoiseLevel,
/// What to do when the hook exits with a non-zero status code. /// What to do when the hook exits with a non-zero status code.
#[serde(default)] #[serde(default)]

View File

@ -5,7 +5,6 @@ template = "test.sh"
[[pre_commit]] [[pre_commit]]
name = "Pre Commit 1" name = "Pre Commit 1"
noise_level = "quiet"
command = "exit 0" command = "exit 0"
staged = ["*.txt"] staged = ["*.txt"]
on_failure = "continue" on_failure = "continue"

View File

@ -9,7 +9,7 @@ use insta::assert_snapshot;
fn test_serialize() { fn test_serialize() {
let pre_commit_command = PreCommit { let pre_commit_command = PreCommit {
name: Some("Command Test".to_string()), name: Some("Command Test".to_string()),
noise_level: NoiseLevel::Quiet, noise_level: None,
on_failure: ExitAction::Continue, on_failure: ExitAction::Continue,
staged: vec!["*.txt".to_string()], staged: vec!["*.txt".to_string()],
task: Task { task: Task {
@ -20,7 +20,7 @@ fn test_serialize() {
let pre_commit_script = PreCommit { let pre_commit_script = PreCommit {
name: Some("Script Test".to_string()), name: Some("Script Test".to_string()),
noise_level: NoiseLevel::Loud, noise_level: Some(NoiseLevel::Loud),
on_failure: ExitAction::Stop, on_failure: ExitAction::Stop,
staged: vec![], staged: vec![],
task: Task { task: Task {

View File

@ -12,7 +12,7 @@ Config {
pre_commit: [ pre_commit: [
PreCommit { PreCommit {
name: None, name: None,
noise_level: Standard, noise_level: None,
on_failure: Stop, on_failure: Stop,
staged: [], staged: [],
task: Task { task: Task {

View File

@ -16,7 +16,7 @@ Config {
name: Some( name: Some(
"Pre Commit 1", "Pre Commit 1",
), ),
noise_level: Quiet, noise_level: None,
on_failure: Continue, on_failure: Continue,
staged: [ staged: [
"*.txt", "*.txt",
@ -32,7 +32,9 @@ Config {
name: Some( name: Some(
"Pre Commit 2", "Pre Commit 2",
), ),
noise_level: Loud, noise_level: Some(
Loud,
),
on_failure: Stop, on_failure: Stop,
staged: [], staged: [],
task: Task { task: Task {

View File

@ -9,7 +9,6 @@ noise_level = 'standard'
[[pre_commit]] [[pre_commit]]
name = 'Command Test' name = 'Command Test'
noise_level = 'quiet'
on_failure = 'continue' on_failure = 'continue'
staged = ['*.txt'] staged = ['*.txt']
command = 'exit 0' command = 'exit 0'