Merge branch 'main' of https://github.com/jacobtread/zed into feat-git-commit-list

This commit is contained in:
Jacobtread 2025-08-18 00:03:18 +12:00
commit c79046effc
490 changed files with 21892 additions and 14140 deletions

View file

@ -414,6 +414,7 @@ impl GitStore {
pub fn init(client: &AnyProtoClient) {
client.add_entity_request_handler(Self::handle_get_remotes);
client.add_entity_request_handler(Self::handle_get_branches);
client.add_entity_request_handler(Self::handle_get_default_branch);
client.add_entity_request_handler(Self::handle_change_branch);
client.add_entity_request_handler(Self::handle_create_branch);
client.add_entity_request_handler(Self::handle_git_init);
@ -441,6 +442,7 @@ impl GitStore {
client.add_entity_request_handler(Self::handle_blame_buffer);
client.add_entity_message_handler(Self::handle_update_repository);
client.add_entity_message_handler(Self::handle_remove_repository);
client.add_entity_request_handler(Self::handle_git_clone);
}
pub fn is_local(&self) -> bool {
@ -1464,6 +1466,45 @@ impl GitStore {
}
}
pub fn git_clone(
&self,
repo: String,
path: impl Into<Arc<std::path::Path>>,
cx: &App,
) -> Task<Result<()>> {
let path = path.into();
match &self.state {
GitStoreState::Local { fs, .. } => {
let fs = fs.clone();
cx.background_executor()
.spawn(async move { fs.git_clone(&repo, &path).await })
}
GitStoreState::Ssh {
upstream_client,
upstream_project_id,
..
} => {
let request = upstream_client.request(proto::GitClone {
project_id: upstream_project_id.0,
abs_path: path.to_string_lossy().to_string(),
remote_repo: repo,
});
cx.background_spawn(async move {
let result = request.await?;
match result.success {
true => Ok(()),
false => Err(anyhow!("Git Clone failed")),
}
})
}
GitStoreState::Remote { .. } => {
Task::ready(Err(anyhow!("Git Clone isn't supported for remote users")))
}
}
}
async fn handle_update_repository(
this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateRepository>,
@ -1550,6 +1591,22 @@ impl GitStore {
Ok(proto::Ack {})
}
async fn handle_git_clone(
this: Entity<Self>,
envelope: TypedEnvelope<proto::GitClone>,
cx: AsyncApp,
) -> Result<proto::GitCloneResponse> {
let path: Arc<Path> = PathBuf::from(envelope.payload.abs_path).into();
let repo_name = envelope.payload.remote_repo;
let result = cx
.update(|cx| this.read(cx).git_clone(repo_name, path, cx))?
.await;
Ok(proto::GitCloneResponse {
success: result.is_ok(),
})
}
async fn handle_fetch(
this: Entity<Self>,
envelope: TypedEnvelope<proto::Fetch>,
@ -1838,6 +1895,23 @@ impl GitStore {
.collect::<Vec<_>>(),
})
}
async fn handle_get_default_branch(
this: Entity<Self>,
envelope: TypedEnvelope<proto::GetDefaultBranch>,
mut cx: AsyncApp,
) -> Result<proto::GetDefaultBranchResponse> {
let repository_id = RepositoryId::from_proto(envelope.payload.repository_id);
let repository_handle = Self::repository_for_request(&this, repository_id, &mut cx)?;
let branch = repository_handle
.update(&mut cx, |repository_handle, _| {
repository_handle.default_branch()
})?
.await??
.map(Into::into);
Ok(proto::GetDefaultBranchResponse { branch })
}
async fn handle_create_branch(
this: Entity<Self>,
envelope: TypedEnvelope<proto::GitCreateBranch>,
@ -2275,7 +2349,7 @@ impl GitStore {
return None;
};
let mut paths = vec![];
let mut paths = Vec::new();
// All paths prefixed by a given repo will constitute a continuous range.
while let Some(path) = entries.get(ix)
&& let Some(repo_path) =
@ -2284,7 +2358,11 @@ impl GitStore {
paths.push((repo_path, ix));
ix += 1;
}
Some((repo, paths))
if paths.is_empty() {
None
} else {
Some((repo, paths))
}
});
tasks.push_back(task);
}
@ -4299,7 +4377,8 @@ impl Repository {
bail!("not a local repository")
};
let (snapshot, events) = this
.read_with(&mut cx, |this, _| {
.update(&mut cx, |this, _| {
this.paths_needing_status_update.clear();
compute_snapshot(
this.id,
this.work_directory_abs_path.clone(),
@ -4529,6 +4608,9 @@ impl Repository {
};
let paths = changed_paths.iter().cloned().collect::<Vec<_>>();
if paths.is_empty() {
return Ok(());
}
let statuses = backend.status(&paths).await?;
let changed_path_statuses = cx