Skip to main content

semver_common/tools/git/
auth.rs

1pub mod github;
2
3use r_log::Logger;
4use serde::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7use crate::Alert;
8
9#[derive(Serialize, Deserialize, PartialEq, Debug)]
10pub enum Auth {
11    GITHUB,
12    NONE,
13}
14
15impl Auth {
16    /// Performs authentication with repository service based on which state Auth is.
17    /// Supplies the environment variables from the running environment.
18    pub fn authenticate(
19        &self,
20        env: &HashMap<String, String>,
21        logger: &Logger,
22    ) -> Result<(), Alert> {
23        match self {
24            Self::GITHUB => {
25                github::set_remote(env, logger)?;
26            }
27            Self::NONE => {}
28        }
29        Ok(())
30    }
31}