feat(config): rename property type as forge_type
This commit is contained in:
parent
cd8d236940
commit
cb0a7f7cd7
2 changed files with 6 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
[forge.default]
|
[forge.default]
|
||||||
type = "forgejo"
|
forge_type = "forgejo"
|
||||||
url = "https://git.example.net"
|
url = "https://git.example.net"
|
||||||
user = "git-next" # the user to perform actions as
|
user = "git-next" # the user to perform actions as
|
||||||
# API token for user?
|
# API token for user?
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::filesystem::FileSystem;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
r#type: ForgeType,
|
forge_type: ForgeType,
|
||||||
url: String,
|
url: String,
|
||||||
user: String,
|
user: String,
|
||||||
// API Token
|
// API Token
|
||||||
|
@ -26,8 +26,8 @@ impl Config {
|
||||||
let str = fs.read_file("git-next-server.toml").map_err(OneOf::new)?;
|
let str = fs.read_file("git-next-server.toml").map_err(OneOf::new)?;
|
||||||
toml::from_str(&str).map_err(OneOf::new)
|
toml::from_str(&str).map_err(OneOf::new)
|
||||||
}
|
}
|
||||||
pub const fn r#type(&self) -> &ForgeType {
|
pub const fn forge_type(&self) -> &ForgeType {
|
||||||
&self.r#type
|
&self.forge_type
|
||||||
}
|
}
|
||||||
pub fn url(&self) -> &str {
|
pub fn url(&self) -> &str {
|
||||||
self.url.as_str()
|
self.url.as_str()
|
||||||
|
@ -49,14 +49,14 @@ mod tests {
|
||||||
fs.write_file(
|
fs.write_file(
|
||||||
"git-next-server.toml",
|
"git-next-server.toml",
|
||||||
r#"
|
r#"
|
||||||
type = "ForgeJo"
|
forge_type = "ForgeJo"
|
||||||
url = "https://forge.jo"
|
url = "https://forge.jo"
|
||||||
user = "Bob"
|
user = "Bob"
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.map_err(OneOf::new)?;
|
.map_err(OneOf::new)?;
|
||||||
let config = Config::load(&fs)?;
|
let config = Config::load(&fs)?;
|
||||||
assert_eq!(config.r#type(), &ForgeType::ForgeJo);
|
assert_eq!(config.forge_type(), &ForgeType::ForgeJo);
|
||||||
assert_eq!(config.url(), "https://forge.jo".to_string());
|
assert_eq!(config.url(), "https://forge.jo".to_string());
|
||||||
assert_eq!(config.user(), "Bob".to_string());
|
assert_eq!(config.user(), "Bob".to_string());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue