Git uncommit warning (#25977)
Adds a prompt when clicking the uncommit button when the current commit is already present on a remote branch:  Release Notes: - N/A --------- Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
parent
0200dda83d
commit
e505d6bf5b
6 changed files with 171 additions and 19 deletions
|
@ -110,6 +110,7 @@ impl GitStore {
|
|||
client.add_entity_request_handler(Self::handle_checkout_files);
|
||||
client.add_entity_request_handler(Self::handle_open_commit_message_buffer);
|
||||
client.add_entity_request_handler(Self::handle_set_index_text);
|
||||
client.add_entity_request_handler(Self::handle_check_for_pushed_commits);
|
||||
}
|
||||
|
||||
pub fn active_repository(&self) -> Option<Entity<Repository>> {
|
||||
|
@ -627,6 +628,29 @@ impl GitStore {
|
|||
})
|
||||
}
|
||||
|
||||
async fn handle_check_for_pushed_commits(
|
||||
this: Entity<Self>,
|
||||
envelope: TypedEnvelope<proto::CheckForPushedCommits>,
|
||||
mut cx: AsyncApp,
|
||||
) -> Result<proto::CheckForPushedCommitsResponse> {
|
||||
let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id);
|
||||
let work_directory_id = ProjectEntryId::from_proto(envelope.payload.work_directory_id);
|
||||
let repository_handle =
|
||||
Self::repository_for_request(&this, worktree_id, work_directory_id, &mut cx)?;
|
||||
|
||||
let branches = repository_handle
|
||||
.update(&mut cx, |repository_handle, _| {
|
||||
repository_handle.check_for_pushed_commits()
|
||||
})?
|
||||
.await??;
|
||||
Ok(proto::CheckForPushedCommitsResponse {
|
||||
pushed_to: branches
|
||||
.into_iter()
|
||||
.map(|commit| commit.to_string())
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
|
||||
fn repository_for_request(
|
||||
this: &Entity<Self>,
|
||||
worktree_id: WorktreeId,
|
||||
|
@ -1423,4 +1447,30 @@ impl Repository {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn check_for_pushed_commits(&self) -> oneshot::Receiver<Result<Vec<SharedString>>> {
|
||||
self.send_job(|repo| async move {
|
||||
match repo {
|
||||
GitRepo::Local(git_repository) => git_repository.check_for_pushed_commit(),
|
||||
GitRepo::Remote {
|
||||
project_id,
|
||||
client,
|
||||
worktree_id,
|
||||
work_directory_id,
|
||||
} => {
|
||||
let response = client
|
||||
.request(proto::CheckForPushedCommits {
|
||||
project_id: project_id.0,
|
||||
worktree_id: worktree_id.to_proto(),
|
||||
work_directory_id: work_directory_id.to_proto(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
let branches = response.pushed_to.into_iter().map(Into::into).collect();
|
||||
|
||||
Ok(branches)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue