Centralize Gitea domain workflows
This commit is contained in:
@@ -10,7 +10,7 @@ use std::{
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
|
||||
|
||||
use gotcha_gitea::{Client, Url};
|
||||
use gotcha_gitea::{Client, RepositoryId, Url};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
type Result<T> = std::result::Result<T, String>;
|
||||
@@ -36,26 +36,7 @@ pub struct Selection {
|
||||
pub repository: Option<RepositoryScope>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RepositoryScope {
|
||||
pub owner: String,
|
||||
pub repository: String,
|
||||
}
|
||||
|
||||
impl RepositoryScope {
|
||||
pub fn parse(value: &str) -> Result<Self> {
|
||||
let (owner, repository) = value
|
||||
.split_once('/')
|
||||
.ok_or("repository must be OWNER/REPOSITORY")?;
|
||||
if owner.is_empty() || repository.is_empty() || repository.contains('/') {
|
||||
return Err("repository must be OWNER/REPOSITORY".into());
|
||||
}
|
||||
Ok(Self {
|
||||
owner: owner.into(),
|
||||
repository: repository.into(),
|
||||
})
|
||||
}
|
||||
}
|
||||
pub type RepositoryScope = RepositoryId;
|
||||
|
||||
impl Config {
|
||||
pub fn load() -> Result<Self> {
|
||||
|
||||
Reference in New Issue
Block a user