git: Improvements to fetch/push/pull (#26041)

- Add global handlers so these actions can be invoked from the command
palette, etc.
- Tweak spinner to not show itself until a remote has been selected

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-03-04 12:37:11 -05:00 committed by GitHub
parent 85211889e5
commit 0453cb2b06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 40 additions and 8 deletions

View file

@ -4,6 +4,7 @@ use git_panel_settings::GitPanelSettings;
use gpui::App;
use project_diff::ProjectDiff;
use ui::{ActiveTheme, Color, Icon, IconName, IntoElement};
use workspace::Workspace;
pub mod branch_picker;
mod commit_modal;
@ -19,6 +20,34 @@ pub fn init(cx: &mut App) {
branch_picker::init(cx);
cx.observe_new(ProjectDiff::register).detach();
commit_modal::init(cx);
cx.observe_new(|workspace: &mut Workspace, _, _| {
workspace.register_action(|workspace, fetch: &git::Fetch, window, cx| {
let Some(panel) = workspace.panel::<git_panel::GitPanel>(cx) else {
return;
};
panel.update(cx, |panel, cx| {
panel.fetch(fetch, window, cx);
});
});
workspace.register_action(|workspace, push: &git::Push, window, cx| {
let Some(panel) = workspace.panel::<git_panel::GitPanel>(cx) else {
return;
};
panel.update(cx, |panel, cx| {
panel.push(push, window, cx);
});
});
workspace.register_action(|workspace, pull: &git::Pull, window, cx| {
let Some(panel) = workspace.panel::<git_panel::GitPanel>(cx) else {
return;
};
panel.update(cx, |panel, cx| {
panel.pull(pull, window, cx);
});
});
})
.detach();
}
// TODO: Add updated status colors to theme