forked from kemitix/git-next
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,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub const fn gitdir(&self) -> Option<&GitDir> {
|
||||||
|
self.gitdir.as_ref()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
impl AsRef<Self> for ServerRepoConfig {
|
impl AsRef<Self> for ServerRepoConfig {
|
||||||
|
@ -324,6 +327,7 @@ pub struct RepoDetails {
|
||||||
pub branch: BranchName,
|
pub branch: BranchName,
|
||||||
pub forge: ForgeDetails,
|
pub forge: ForgeDetails,
|
||||||
pub config: Option<RepoConfig>,
|
pub config: Option<RepoConfig>,
|
||||||
|
pub gitdir: Option<GitDir>,
|
||||||
}
|
}
|
||||||
impl RepoDetails {
|
impl RepoDetails {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
@ -337,6 +341,7 @@ impl RepoDetails {
|
||||||
repo_path: RepoPath(server_repo_config.repo.clone()),
|
repo_path: RepoPath(server_repo_config.repo.clone()),
|
||||||
config: server_repo_config.repo_config(),
|
config: server_repo_config.repo_config(),
|
||||||
branch: BranchName(server_repo_config.branch.clone()),
|
branch: BranchName(server_repo_config.branch.clone()),
|
||||||
|
gitdir: server_repo_config.gitdir().cloned(),
|
||||||
forge: ForgeDetails {
|
forge: ForgeDetails {
|
||||||
name: forge_name.clone(),
|
name: forge_name.clone(),
|
||||||
forge_type: forge.forge_type.clone(),
|
forge_type: forge.forge_type.clone(),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::server::config::{
|
use crate::server::config::{
|
||||||
ApiToken, BranchName, ForgeDetails, ForgeName, ForgeType, Hostname, RepoAlias, RepoBranches,
|
ApiToken, BranchName, ForgeDetails, ForgeName, ForgeType, GitDir, Hostname, RepoAlias,
|
||||||
RepoConfig, RepoDetails, RepoPath, User,
|
RepoBranches, RepoConfig, RepoDetails, RepoPath, User,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn forge_details(n: u32, forge_type: ForgeType) -> ForgeDetails {
|
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 {
|
pub fn forge_name(n: u32) -> ForgeName {
|
||||||
ForgeName(format!("forge-name-{}", n))
|
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 {
|
RepoDetails {
|
||||||
name: repo_alias(n),
|
name: repo_alias(n),
|
||||||
repo_path: repo_path(n),
|
repo_path: repo_path(n),
|
||||||
|
gitdir,
|
||||||
branch: branch_name(n),
|
branch: branch_name(n),
|
||||||
forge,
|
forge,
|
||||||
config,
|
config,
|
||||||
|
|
|
@ -13,6 +13,7 @@ fn test_name() {
|
||||||
1,
|
1,
|
||||||
common::forge_details(1, ForgeType::MockForge),
|
common::forge_details(1, ForgeType::MockForge),
|
||||||
Some(common::config(1)),
|
Some(common::config(1)),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
let forge = Forge::new_forgejo(repo_details, net);
|
let forge = Forge::new_forgejo(repo_details, net);
|
||||||
assert_eq!(forge.name(), "forgejo");
|
assert_eq!(forge.name(), "forgejo");
|
||||||
|
@ -35,6 +36,7 @@ async fn test_branches_get() {
|
||||||
1,
|
1,
|
||||||
common::forge_details(1, ForgeType::MockForge),
|
common::forge_details(1, ForgeType::MockForge),
|
||||||
Some(common::config(1)),
|
Some(common::config(1)),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
let forge = Forge::new_forgejo(repo_details, net.clone());
|
let forge = Forge::new_forgejo(repo_details, net.clone());
|
||||||
|
|
Loading…
Reference in a new issue