diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index c68743d3..ee5871f3 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -195,3 +195,20 @@ pub fn is_enabled(cfg: &Value) -> bool { get_bool_cfg(Some(cfg), "enabled", true, true) } +/// Check whether committing is enabled for a hook. +pub fn committing_is_enabled(cfg: &Value) -> Result { + match cfg.lookup("commit.enabled") { + Some(&Value::Boolean(b)) => Ok(b), + Some(_) => { + warn!("Config setting whether committing is enabled or not has wrong type."); + warn!("Expected Boolean"); + Err(GHEK::ConfigTypeError.into_error()) + }, + None => { + warn!("No config setting whether committing is enabled or not."); + Err(GHEK::NoConfigError.into_error()) + }, + } + .map_err_into(GHEK::ConfigError) +} +