mit_commit_message_lints/mit/cmd/get_config_rotation.rs
1use miette::Result;
2
3use crate::{external::Vcs, mit::lib::rotation_option::RotationOption};
4
5/// Get the rotation configuration setting
6///
7/// Returns `None` when rotation is not configured (rotation is off).
8/// Returns `Some(RotationOption::RoundRobin)` when round-robin rotation
9/// is enabled.
10///
11/// # Errors
12///
13/// Returns an error if reading the git config fails, or if the stored
14/// value cannot be parsed as a valid rotation option.
15pub fn get_config_rotation(store: &dyn Vcs) -> Result<Option<RotationOption>> {
16 match store.get_str(super::CONFIG_KEY_ROTATION)?.map(String::from) {
17 Some(s) => Ok(Some(s.parse()?)),
18 None => Ok(None),
19 }
20}