Change summary
crates/fs/src/fake_git_repo.rs | 4 ++++
crates/git/src/repository.rs | 13 +++++++++++++
crates/project/src/git_store.rs | 27 +++++++++++++++++++++++++++
3 files changed, 44 insertions(+)
Detailed changes
@@ -1306,6 +1306,10 @@ impl GitRepository for FakeGitRepository {
})
}
+ fn repair_worktrees(&self) -> BoxFuture<'_, Result<()>> {
+ async { Ok(()) }.boxed()
+ }
+
fn set_trusted(&self, trusted: bool) {
self.is_trusted
.store(trusted, std::sync::atomic::Ordering::Release);
@@ -921,6 +921,8 @@ pub trait GitRepository: Send + Sync {
fn delete_ref(&self, ref_name: String) -> BoxFuture<'_, Result<()>>;
+ fn repair_worktrees(&self) -> BoxFuture<'_, Result<()>>;
+
fn set_trusted(&self, trusted: bool);
fn is_trusted(&self) -> bool;
}
@@ -2208,6 +2210,17 @@ impl GitRepository for RealGitRepository {
.boxed()
}
+ fn repair_worktrees(&self) -> BoxFuture<'_, Result<()>> {
+ let git_binary = self.git_binary();
+ self.executor
+ .spawn(async move {
+ let args: Vec<OsString> = vec!["worktree".into(), "repair".into()];
+ git_binary?.run(&args).await?;
+ Ok(())
+ })
+ .boxed()
+ }
+
fn push(
&self,
branch_name: String,
@@ -6118,6 +6118,33 @@ impl Repository {
})
}
+ pub fn resolve_commit(&mut self, sha: String) -> oneshot::Receiver<Result<bool>> {
+ self.send_job(None, move |repo, _cx| async move {
+ match repo {
+ RepositoryState::Local(LocalRepositoryState { backend, .. }) => {
+ let results = backend.revparse_batch(vec![sha]).await?;
+ Ok(results.into_iter().next().flatten().is_some())
+ }
+ RepositoryState::Remote(_) => {
+ anyhow::bail!("resolve_commit is not supported for remote repositories")
+ }
+ }
+ })
+ }
+
+ pub fn repair_worktrees(&mut self) -> oneshot::Receiver<Result<()>> {
+ self.send_job(None, move |repo, _cx| async move {
+ match repo {
+ RepositoryState::Local(LocalRepositoryState { backend, .. }) => {
+ backend.repair_worktrees().await
+ }
+ RepositoryState::Remote(_) => {
+ anyhow::bail!("repair_worktrees is not supported for remote repositories")
+ }
+ }
+ })
+ }
+
pub fn remove_worktree(&mut self, path: PathBuf, force: bool) -> oneshot::Receiver<Result<()>> {
let id = self.id;
self.send_job(