git: Amend (#28187)
Adds git amend support. - [x] Turn existing commit button into split button - [x] Clean up + Handle shortcuts/focus cases - [x] Test remote Release Notes: - Added git amend support. --------- Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
parent
ac8a4ba5d4
commit
78ecc3cef0
11 changed files with 595 additions and 84 deletions
|
@ -21,7 +21,7 @@ use git::{
|
|||
blame::Blame,
|
||||
parse_git_remote_url,
|
||||
repository::{
|
||||
Branch, CommitDetails, CommitDiff, CommitFile, DiffType, GitRepository,
|
||||
Branch, CommitDetails, CommitDiff, CommitFile, CommitOptions, DiffType, GitRepository,
|
||||
GitRepositoryCheckpoint, PushOptions, Remote, RemoteCommandOutput, RepoPath, ResetMode,
|
||||
UpstreamTrackingStatus,
|
||||
},
|
||||
|
@ -1656,10 +1656,18 @@ impl GitStore {
|
|||
let message = SharedString::from(envelope.payload.message);
|
||||
let name = envelope.payload.name.map(SharedString::from);
|
||||
let email = envelope.payload.email.map(SharedString::from);
|
||||
let options = envelope.payload.options.unwrap_or_default();
|
||||
|
||||
repository_handle
|
||||
.update(&mut cx, |repository_handle, cx| {
|
||||
repository_handle.commit(message, name.zip(email), cx)
|
||||
repository_handle.commit(
|
||||
message,
|
||||
name.zip(email),
|
||||
CommitOptions {
|
||||
amend: options.amend,
|
||||
},
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await??;
|
||||
Ok(proto::Ack {})
|
||||
|
@ -3248,6 +3256,7 @@ impl Repository {
|
|||
&mut self,
|
||||
message: SharedString,
|
||||
name_and_email: Option<(SharedString, SharedString)>,
|
||||
options: CommitOptions,
|
||||
_cx: &mut App,
|
||||
) -> oneshot::Receiver<Result<()>> {
|
||||
let id = self.id;
|
||||
|
@ -3258,7 +3267,11 @@ impl Repository {
|
|||
backend,
|
||||
environment,
|
||||
..
|
||||
} => backend.commit(message, name_and_email, environment).await,
|
||||
} => {
|
||||
backend
|
||||
.commit(message, name_and_email, options, environment)
|
||||
.await
|
||||
}
|
||||
RepositoryState::Remote { project_id, client } => {
|
||||
let (name, email) = name_and_email.unzip();
|
||||
client
|
||||
|
@ -3268,6 +3281,9 @@ impl Repository {
|
|||
message: String::from(message),
|
||||
name: name.map(String::from),
|
||||
email: email.map(String::from),
|
||||
options: Some(proto::commit::CommitOptions {
|
||||
amend: options.amend,
|
||||
}),
|
||||
})
|
||||
.await
|
||||
.context("sending commit request")?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue