use std::path::{Path, PathBuf};
use super::{Repo, RepoError};
#[derive(Debug, Default, Clone)]
#[non_exhaustive]
pub struct InitOptions {}
impl Repo {
pub async fn init(path: impl AsRef<Path>, _opts: InitOptions) -> Result<Self, RepoError> {
let path: PathBuf = path.as_ref().to_path_buf();
let path_for_task = path.clone();
tokio::task::spawn_blocking(move || {
let repo = gix::init(&path_for_task).map_err(|e| RepoError::InitFailed {
path: path_for_task.clone(),
cause: e.to_string(),
})?;
Ok::<_, RepoError>(Self::from_thread_safe(repo.into_sync(), path_for_task))
})
.await
.map_err(|join_err| RepoError::InitFailed {
path: path.clone(),
cause: format!("spawn_blocking join error: {join_err}"),
})?
}
}