Skip to main content

mit_commit_message_lints/mit/cmd/
set_config_authors.rs

1use miette::Result;
2
3use crate::{external::Vcs, mit::Author};
4/// # Errors
5///
6/// On write failure
7pub fn set_config_authors(store: &mut dyn Vcs, initial: &str, author: &Author<'_>) -> Result<()> {
8    store.set_str(
9        &format!("mit.author.config.{initial}.email"),
10        author.email(),
11    )?;
12    store.set_str(&format!("mit.author.config.{initial}.name"), author.name())?;
13
14    match author.signingkey() {
15        Some(signingkey) => {
16            store.set_str(
17                &format!("mit.author.config.{initial}.signingkey"),
18                signingkey,
19            )?;
20        }
21        None => {
22            store.remove(&format!("mit.author.config.{initial}.signingkey"))?;
23        }
24    }
25
26    Ok(())
27}