forked from kemitix/git-next
feat(config): add ForgeDetails and RepoDetails types
This commit is contained in:
parent
634b040708
commit
3ac4894d68
1 changed files with 42 additions and 1 deletions
|
@ -39,7 +39,48 @@ impl Forge {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Deserialize)]
|
||||
#[derive(Clone)]
|
||||
pub struct ForgeName(pub String);
|
||||
impl Display for ForgeName {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
pub struct Hostname(pub String);
|
||||
pub struct User(pub String);
|
||||
pub struct ForgeDetails {
|
||||
pub name: ForgeName,
|
||||
pub forge_type: ForgeType,
|
||||
pub hostname: Hostname,
|
||||
pub user: User,
|
||||
// API Token
|
||||
// Private SSH Key Path
|
||||
}
|
||||
impl From<(&ForgeName, &Forge)> for ForgeDetails {
|
||||
fn from(forge: (&ForgeName, &Forge)) -> Self {
|
||||
Self {
|
||||
name: forge.0.clone(),
|
||||
forge_type: forge.1.forge_type.clone(),
|
||||
hostname: Hostname(forge.1.hostname.clone()),
|
||||
user: User(forge.1.user.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct RepoName(pub String);
|
||||
impl Display for RepoName {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
pub struct RepoPath(pub String);
|
||||
pub struct RepoDetails {
|
||||
pub name: RepoName,
|
||||
pub path: RepoPath,
|
||||
pub forge: ForgeDetails,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
|
||||
pub enum ForgeType {
|
||||
ForgeJo,
|
||||
// Gitea,
|
||||
|
|
Loading…
Reference in a new issue