2024-06-09 10:21:09 +01:00
|
|
|
//
|
2024-05-19 15:05:24 +01:00
|
|
|
use std::sync::atomic::AtomicBool;
|
|
|
|
|
2024-06-09 10:21:09 +01:00
|
|
|
use crate as git;
|
2024-05-19 15:05:24 +01:00
|
|
|
use derive_more::Deref as _;
|
|
|
|
use git_next_config::GitDir;
|
|
|
|
|
2024-05-19 14:57:58 +01:00
|
|
|
pub struct RealRepository;
|
2024-06-09 10:21:09 +01:00
|
|
|
impl git::repository::RepositoryLike for RealRepository {
|
|
|
|
fn open(&self, gitdir: &GitDir) -> Result<git::OpenRepository, git::repository::Error> {
|
2024-05-19 15:05:24 +01:00
|
|
|
let gix_repo = gix::ThreadSafeRepository::open(gitdir.to_path_buf())?.to_thread_local();
|
2024-06-09 10:21:09 +01:00
|
|
|
Ok(git::repository::open::real(gix_repo))
|
2024-05-19 14:57:58 +01:00
|
|
|
}
|
|
|
|
|
2024-05-25 11:25:13 +01:00
|
|
|
#[tracing::instrument(skip_all)]
|
2024-06-09 10:21:09 +01:00
|
|
|
#[cfg(not(tarpaulin_include))] // requires external server
|
|
|
|
fn git_clone(
|
|
|
|
&self,
|
|
|
|
repo_details: &git::RepoDetails,
|
|
|
|
) -> Result<git::OpenRepository, git::repository::Error> {
|
2024-05-25 11:25:13 +01:00
|
|
|
tracing::info!("creating");
|
2024-05-19 14:57:58 +01:00
|
|
|
use secrecy::ExposeSecret;
|
2024-05-19 15:05:24 +01:00
|
|
|
let (gix_repo, _outcome) = gix::prepare_clone_bare(
|
|
|
|
repo_details.origin().expose_secret().as_str(),
|
|
|
|
repo_details.gitdir.deref(),
|
|
|
|
)?
|
|
|
|
.fetch_only(gix::progress::Discard, &AtomicBool::new(false))?;
|
2024-05-25 11:25:13 +01:00
|
|
|
tracing::info!("created");
|
2024-05-19 14:57:58 +01:00
|
|
|
|
2024-06-09 10:21:09 +01:00
|
|
|
Ok(git::repository::open::real(gix_repo))
|
2024-05-19 14:57:58 +01:00
|
|
|
}
|
|
|
|
}
|