Skip to content

Commit 7bcc94e

Browse files
committed
Rename GitProvider to GitProviderType and move it to config module
1 parent 94b200e commit 7bcc94e

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

src/cli/manage_sources.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::GitProvider;
1+
use crate::config;
22
use clap::Subcommand;
33

44
#[derive(Debug, Subcommand)]
@@ -9,7 +9,7 @@ pub enum ManageSources {
99
name: String,
1010
/// The Git provider used by the source.
1111
#[arg(short, long)]
12-
provider: GitProvider,
12+
provider: config::GitProviderType,
1313
/// The URL of the source.
1414
#[arg(short, long)]
1515
url: Option<reqwest::Url>,

src/config.rs

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::GitProvider;
21
use figment::{
32
providers::{Format, Serialized, Toml},
43
Figment,
@@ -31,12 +30,12 @@ impl Default for Config {
3130
sources: Some(vec![
3231
Source {
3332
name: "github".to_string(),
34-
provider: GitProvider::Github,
33+
provider: GitProviderType::Github,
3534
url: "https://api.github.com".to_string(),
3635
},
3736
Source {
3837
name: "gitlab".to_string(),
39-
provider: GitProvider::Gitlab,
38+
provider: GitProviderType::Gitlab,
4039
url: "https://gitlab.com".to_string(),
4140
},
4241
]),
@@ -83,6 +82,16 @@ fn git_allowed_signers() -> Option<PathBuf> {
8382
Some(path.into())
8483
}
8584

85+
/// The type of Git provider.
86+
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, clap::ValueEnum)]
87+
#[serde(rename_all = "lowercase")]
88+
pub enum GitProviderType {
89+
/// A Git provider that implements the GitHub API.
90+
Github,
91+
/// A Git provider that implements the GitLab API.
92+
Gitlab,
93+
}
94+
8695
#[derive(Debug, Deserialize, Serialize, PartialEq)]
8796
struct User {
8897
name: String,
@@ -98,7 +107,7 @@ struct Organization {
98107
#[derive(Debug, Deserialize, Serialize, PartialEq)]
99108
struct Source {
100109
name: String,
101-
provider: GitProvider,
110+
provider: GitProviderType,
102111
url: String,
103112
}
104113

@@ -168,17 +177,17 @@ mod tests {
168177
sources: Some(vec![
169178
Source {
170179
name: "github".to_string(),
171-
provider: GitProvider::Github,
180+
provider: GitProviderType::Github,
172181
url: "https://api.github.com".to_string(),
173182
},
174183
Source {
175184
name: "gitlab".to_string(),
176-
provider: GitProvider::Gitlab,
185+
provider: GitProviderType::Gitlab,
177186
url: "https://gitlab.com".to_string(),
178187
},
179188
Source {
180189
name: "acme-corp".to_string(),
181-
provider: GitProvider::Gitlab,
190+
provider: GitProviderType::Gitlab,
182191
url: "https://git.acme.corp".to_string(),
183192
},
184193
])

src/core.rs

-8
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,3 @@ pub trait GetPublicKeys {
3030
/// Get the public keys of a user by their username.
3131
async fn by_username(&self, username: &str) -> Result<Vec<SshPublicKey>, Self::Err>;
3232
}
33-
34-
/// A Git provider.
35-
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, clap::ValueEnum)]
36-
#[serde(rename_all = "lowercase")]
37-
pub enum GitProvider {
38-
Github,
39-
Gitlab,
40-
}

0 commit comments

Comments
 (0)