From df397b2cdaa1e86f4b732bde2483ccdb796d25e0 Mon Sep 17 00:00:00 2001 From: Bauke Date: Thu, 18 Jan 2024 12:27:27 +0100 Subject: [PATCH] Make noise_level optional for hooks. --- hooked-config/source/config/pre_commit.rs | 3 +-- hooked-config/tests/parsing/with-hooks.toml | 1 - hooked-config/tests/serialize.rs | 4 ++-- hooked-config/tests/snapshots/parsing__defaults.snap | 2 +- hooked-config/tests/snapshots/parsing__with-hooks.snap | 6 ++++-- hooked-config/tests/snapshots/serialize__serialize.snap | 1 - 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hooked-config/source/config/pre_commit.rs b/hooked-config/source/config/pre_commit.rs index b3573fe..5708bad 100644 --- a/hooked-config/source/config/pre_commit.rs +++ b/hooked-config/source/config/pre_commit.rs @@ -12,8 +12,7 @@ pub struct PreCommit { pub name: Option, /// The noise level this task should output with. - #[serde(default)] - pub noise_level: NoiseLevel, + pub noise_level: Option, /// What to do when the hook exits with a non-zero status code. #[serde(default)] diff --git a/hooked-config/tests/parsing/with-hooks.toml b/hooked-config/tests/parsing/with-hooks.toml index 18e6563..59d6478 100644 --- a/hooked-config/tests/parsing/with-hooks.toml +++ b/hooked-config/tests/parsing/with-hooks.toml @@ -5,7 +5,6 @@ template = "test.sh" [[pre_commit]] name = "Pre Commit 1" -noise_level = "quiet" command = "exit 0" staged = ["*.txt"] on_failure = "continue" diff --git a/hooked-config/tests/serialize.rs b/hooked-config/tests/serialize.rs index c54e276..ee847a7 100644 --- a/hooked-config/tests/serialize.rs +++ b/hooked-config/tests/serialize.rs @@ -9,7 +9,7 @@ use insta::assert_snapshot; fn test_serialize() { let pre_commit_command = PreCommit { name: Some("Command Test".to_string()), - noise_level: NoiseLevel::Quiet, + noise_level: None, on_failure: ExitAction::Continue, staged: vec!["*.txt".to_string()], task: Task { @@ -20,7 +20,7 @@ fn test_serialize() { let pre_commit_script = PreCommit { name: Some("Script Test".to_string()), - noise_level: NoiseLevel::Loud, + noise_level: Some(NoiseLevel::Loud), on_failure: ExitAction::Stop, staged: vec![], task: Task { diff --git a/hooked-config/tests/snapshots/parsing__defaults.snap b/hooked-config/tests/snapshots/parsing__defaults.snap index 8e397cf..7370f9d 100644 --- a/hooked-config/tests/snapshots/parsing__defaults.snap +++ b/hooked-config/tests/snapshots/parsing__defaults.snap @@ -12,7 +12,7 @@ Config { pre_commit: [ PreCommit { name: None, - noise_level: Standard, + noise_level: None, on_failure: Stop, staged: [], task: Task { diff --git a/hooked-config/tests/snapshots/parsing__with-hooks.snap b/hooked-config/tests/snapshots/parsing__with-hooks.snap index ed6cdd5..782e56d 100644 --- a/hooked-config/tests/snapshots/parsing__with-hooks.snap +++ b/hooked-config/tests/snapshots/parsing__with-hooks.snap @@ -16,7 +16,7 @@ Config { name: Some( "Pre Commit 1", ), - noise_level: Quiet, + noise_level: None, on_failure: Continue, staged: [ "*.txt", @@ -32,7 +32,9 @@ Config { name: Some( "Pre Commit 2", ), - noise_level: Loud, + noise_level: Some( + Loud, + ), on_failure: Stop, staged: [], task: Task { diff --git a/hooked-config/tests/snapshots/serialize__serialize.snap b/hooked-config/tests/snapshots/serialize__serialize.snap index b38a5bc..0bab86e 100644 --- a/hooked-config/tests/snapshots/serialize__serialize.snap +++ b/hooked-config/tests/snapshots/serialize__serialize.snap @@ -9,7 +9,6 @@ noise_level = 'standard' [[pre_commit]] name = 'Command Test' -noise_level = 'quiet' on_failure = 'continue' staged = ['*.txt'] command = 'exit 0'