feat: add gitdir to RepoDetails type
This commit is contained in:
parent
a024c3de5e
commit
b71aece8c9
3 changed files with 16 additions and 3 deletions
|
@ -199,6 +199,9 @@ impl ServerRepoConfig {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
pub const fn gitdir(&self) -> Option<&GitDir> {
|
||||
self.gitdir.as_ref()
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
impl AsRef<Self> for ServerRepoConfig {
|
||||
|
@ -324,6 +327,7 @@ pub struct RepoDetails {
|
|||
pub branch: BranchName,
|
||||
pub forge: ForgeDetails,
|
||||
pub config: Option<RepoConfig>,
|
||||
pub gitdir: Option<GitDir>,
|
||||
}
|
||||
impl RepoDetails {
|
||||
pub fn new(
|
||||
|
@ -337,6 +341,7 @@ impl RepoDetails {
|
|||
repo_path: RepoPath(server_repo_config.repo.clone()),
|
||||
config: server_repo_config.repo_config(),
|
||||
branch: BranchName(server_repo_config.branch.clone()),
|
||||
gitdir: server_repo_config.gitdir().cloned(),
|
||||
forge: ForgeDetails {
|
||||
name: forge_name.clone(),
|
||||
forge_type: forge.forge_type.clone(),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::server::config::{
|
||||
ApiToken, BranchName, ForgeDetails, ForgeName, ForgeType, Hostname, RepoAlias, RepoBranches,
|
||||
RepoConfig, RepoDetails, RepoPath, User,
|
||||
ApiToken, BranchName, ForgeDetails, ForgeName, ForgeType, GitDir, Hostname, RepoAlias,
|
||||
RepoBranches, RepoConfig, RepoDetails, RepoPath, User,
|
||||
};
|
||||
|
||||
pub fn forge_details(n: u32, forge_type: ForgeType) -> ForgeDetails {
|
||||
|
@ -28,10 +28,16 @@ pub fn hostname(n: u32) -> Hostname {
|
|||
pub fn forge_name(n: u32) -> ForgeName {
|
||||
ForgeName(format!("forge-name-{}", n))
|
||||
}
|
||||
pub fn repo_details(n: u32, forge: ForgeDetails, config: Option<RepoConfig>) -> RepoDetails {
|
||||
pub fn repo_details(
|
||||
n: u32,
|
||||
forge: ForgeDetails,
|
||||
config: Option<RepoConfig>,
|
||||
gitdir: Option<GitDir>,
|
||||
) -> RepoDetails {
|
||||
RepoDetails {
|
||||
name: repo_alias(n),
|
||||
repo_path: repo_path(n),
|
||||
gitdir,
|
||||
branch: branch_name(n),
|
||||
forge,
|
||||
config,
|
||||
|
|
|
@ -13,6 +13,7 @@ fn test_name() {
|
|||
1,
|
||||
common::forge_details(1, ForgeType::MockForge),
|
||||
Some(common::config(1)),
|
||||
None,
|
||||
);
|
||||
let forge = Forge::new_forgejo(repo_details, net);
|
||||
assert_eq!(forge.name(), "forgejo");
|
||||
|
@ -35,6 +36,7 @@ async fn test_branches_get() {
|
|||
1,
|
||||
common::forge_details(1, ForgeType::MockForge),
|
||||
Some(common::config(1)),
|
||||
None,
|
||||
);
|
||||
|
||||
let forge = Forge::new_forgejo(repo_details, net.clone());
|
||||
|
|
Loading…
Reference in a new issue