git: Add uncommit action (#37031)

Alvaro Parker created

Closes #36767

Release Notes:

- Add uncommit action for git

Change summary

crates/git_ui/src/git_panel.rs | 2 +-
crates/git_ui/src/git_ui.rs    | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)

Detailed changes

crates/git_ui/src/git_panel.rs 🔗

@@ -1738,7 +1738,7 @@ impl GitPanel {
         self.pending_commit = Some(task);
     }
 
-    fn uncommit(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+    pub(crate) fn uncommit(&mut self, window: &mut Window, cx: &mut Context<Self>) {
         let Some(repo) = self.active_repository.clone() else {
             return;
         };

crates/git_ui/src/git_ui.rs 🔗

@@ -149,6 +149,14 @@ pub fn init(cx: &mut App) {
                 panel.unstage_all(action, window, cx);
             });
         });
+        workspace.register_action(|workspace, _: &git::Uncommit, window, cx| {
+            let Some(panel) = workspace.panel::<git_panel::GitPanel>(cx) else {
+                return;
+            };
+            panel.update(cx, |panel, cx| {
+                panel.uncommit(window, cx);
+            })
+        });
         CommandPaletteFilter::update_global(cx, |filter, _cx| {
             filter.hide_action_types(&[
                 zed_actions::OpenGitIntegrationOnboarding.type_id(),