Allow for commit amends with no file changes (#37256)
This will users to change the wording of the most recent commit, something they might want to do if they realize they made a small typo of some kind or if the formatting of their commit message is wrong, but don't have any other changes they need to make. Release Notes: - Commit messages can now be amended in the UI without any other changes needing to be made. --------- Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
co-authored by
Cole Miller
parent
816c4817d0
commit
aee21ca17f
@@ -1709,7 +1709,7 @@ impl GitPanel {
|
||||
.map(|status_entry| status_entry.repo_path.clone())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if changed_files.is_empty() {
|
||||
if changed_files.is_empty() && !options.amend {
|
||||
error_spawn("No changes to commit", window, cx);
|
||||
return;
|
||||
}
|
||||
@@ -3295,7 +3295,7 @@ impl GitPanel {
|
||||
pub fn configure_commit_button(&self, cx: &mut Context<Self>) -> (bool, &'static str) {
|
||||
if self.has_unstaged_conflicts() {
|
||||
(false, "You must resolve conflicts before committing")
|
||||
} else if !self.has_staged_changes() && !self.has_tracked_changes() {
|
||||
} else if !self.has_staged_changes() && !self.has_tracked_changes() && !self.amend_pending {
|
||||
(false, "No changes to commit")
|
||||
} else if self.pending_commit.is_some() {
|
||||
(false, "Commit in progress")
|
||||
@@ -3312,8 +3312,10 @@ impl GitPanel {
|
||||
if self.amend_pending {
|
||||
if self.has_staged_changes() {
|
||||
"Amend"
|
||||
} else {
|
||||
} else if self.has_tracked_changes() {
|
||||
"Amend Tracked"
|
||||
} else {
|
||||
"Amend"
|
||||
}
|
||||
} else if self.has_staged_changes() {
|
||||
"Commit"
|
||||
|
||||
Reference in New Issue
Block a user