Fixes to commit button in Git Panel (#24425)

Git Panel updates:

* Fixes commit/commit all button to work (and be disabled correctly in
merge conflict status)
* Updates keyboard shortcuts and sets focus on the button (enter now
does the same as click; tab cycles between editor and change list)


Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...

---------

Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
Conrad Irwin 2025-02-07 00:21:28 -07:00 committed by GitHub
parent 6534e0bafd
commit 1f9d02607b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 202 additions and 268 deletions

View file

@ -38,8 +38,7 @@ actions!(
StageAll,
UnstageAll,
RevertAll,
CommitChanges,
CommitAllChanges,
Commit,
ClearCommitMessage
]
);

View file

@ -293,13 +293,16 @@ impl GitRepository for RealGitRepository {
.to_path_buf();
if !paths.is_empty() {
let status = new_std_command(&self.git_binary_path)
let output = new_std_command(&self.git_binary_path)
.current_dir(&working_directory)
.args(["update-index", "--add", "--remove", "--"])
.args(paths.iter().map(|p| p.as_ref()))
.status()?;
if !status.success() {
return Err(anyhow!("Failed to stage paths: {status}"));
.output()?;
if !output.status.success() {
return Err(anyhow!(
"Failed to stage paths:\n{}",
String::from_utf8_lossy(&output.stderr)
));
}
}
Ok(())
@ -314,13 +317,16 @@ impl GitRepository for RealGitRepository {
.to_path_buf();
if !paths.is_empty() {
let cmd = new_std_command(&self.git_binary_path)
let output = new_std_command(&self.git_binary_path)
.current_dir(&working_directory)
.args(["reset", "--quiet", "--"])
.args(paths.iter().map(|p| p.as_ref()))
.status()?;
if !cmd.success() {
return Err(anyhow!("Failed to unstage paths: {cmd}"));
.output()?;
if !output.status.success() {
return Err(anyhow!(
"Failed to unstage:\n{}",
String::from_utf8_lossy(&output.stderr)
));
}
}
Ok(())
@ -340,12 +346,16 @@ impl GitRepository for RealGitRepository {
args.push(author);
}
let cmd = new_std_command(&self.git_binary_path)
let output = new_std_command(&self.git_binary_path)
.current_dir(&working_directory)
.args(args)
.status()?;
if !cmd.success() {
return Err(anyhow!("Failed to commit: {cmd}"));
.output()?;
if !output.status.success() {
return Err(anyhow!(
"Failed to commit:\n{}",
String::from_utf8_lossy(&output.stderr)
));
}
Ok(())
}