use crate::git::error::GitError;
use crate::git::repo::GitRepo;
use std::path::{Path, PathBuf};
#[derive(Debug, Clone)]
pub struct GitWorktree {
pub(crate) path: PathBuf,
pub(crate) branch: String,
}
impl GitWorktree {
pub fn path(&self) -> &Path {
&self.path
}
pub fn branch(&self) -> &str {
&self.branch
}
pub async fn repo<F, Fut, R>(&self, f: F) -> Result<R, GitError>
where
F: FnOnce(GitRepo) -> Fut,
Fut: std::future::Future<Output = Result<R, GitError>>,
{
let repo = GitRepo::open(&self.path)?;
f(repo).await
}
}