git-next/crates/git/src/repository/real.rs
Paul Campbell 588666ffe1
All checks were successful
Rust / build (push) Successful in 2m22s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
tests: add more tests to git crate
2024-06-13 19:50:19 +01:00

32 lines
1.1 KiB
Rust

//
use std::sync::atomic::AtomicBool;
use crate as git;
use derive_more::Deref as _;
use git_next_config::GitDir;
pub struct RealRepository;
impl git::repository::RepositoryLike for RealRepository {
fn open(&self, gitdir: &GitDir) -> Result<git::OpenRepository, git::repository::Error> {
let gix_repo = gix::ThreadSafeRepository::open(gitdir.to_path_buf())?.to_thread_local();
Ok(git::repository::open::real(gix_repo))
}
#[tracing::instrument(skip_all)]
#[cfg(not(tarpaulin_include))] // requires external server
fn git_clone(
&self,
repo_details: &git::RepoDetails,
) -> Result<git::OpenRepository, git::repository::Error> {
tracing::info!("creating");
use secrecy::ExposeSecret;
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))?;
tracing::info!("created");
Ok(git::repository::open::real(gix_repo))
}
}