Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions crates/git_ui/src/git_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ actions!(
]
);

actions!(
dev,
[
/// Shows the current git job queue debug state for the active repository.
ShowGitJobQueue,
]
);

actions!(
git_graph,
[
Expand Down Expand Up @@ -259,6 +267,13 @@ pub fn register(workspace: &mut Workspace) {
panel.update(cx, |panel, cx| panel.git_init(window, cx));
}
});
workspace.register_action(|workspace, _: &ShowGitJobQueue, window, cx| {
if let Some(panel) = workspace.panel::<GitPanel>(cx) {
panel.update(cx, |panel, cx| {
panel.show_git_job_queue(window, cx);
});
}
});
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -3880,6 +3895,74 @@ impl GitPanel {
show_error_toast(workspace, action, e, cx)
}

fn show_git_job_queue(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let Some(repo) = self.active_repository.as_ref() else {
let workspace = self.workspace.clone();
cx.defer(move |cx| {
if let Some(workspace) = workspace.upgrade() {
workspace.update(cx, |workspace, cx| {
struct GitJobQueueToast;
workspace.show_toast(
workspace::Toast::new(
NotificationId::unique::<GitJobQueueToast>(),
"No active repository",
)
.autohide(),
cx,
);
});
}
});
return;
};

let repo_path = repo.read(cx).work_directory_abs_path.display().to_string();
let text = repo.read(cx).job_debug_queue().to_debug_string();
let title = format!("Git Job Queue: {repo_path}");

let json_language = self.project.read(cx).languages().language_for_name("JSON");
let project = self.project.clone();
let workspace = self.workspace.clone();

window
.spawn(cx, async move |cx| {
let json_language = json_language.await.ok();

let buffer = project
.update(cx, |project, cx| {
project.create_buffer(json_language, false, cx)
})
.await?;

buffer.update(cx, |buffer, cx| {
buffer.set_text(text, cx);
buffer.set_capability(language::Capability::ReadWrite, cx);
});

workspace.update_in(cx, |workspace, window, cx| {
let buffer =
cx.new(|cx| MultiBuffer::singleton(buffer, cx).with_title(title.clone()));

workspace.add_item_to_active_pane(
Box::new(cx.new(|cx| {
let mut editor =
Editor::for_multibuffer(buffer, Some(project.clone()), window, cx);
editor.set_breadcrumb_header(title);
editor.disable_mouse_wheel_zoom();
editor
})),
None,
true,
window,
cx,
);
})?;

anyhow::Ok(())
})
.detach_and_log_err(cx);
}

fn show_commit_message_error<E>(weak_this: &WeakEntity<Self>, err: &E, cx: &mut AsyncApp)
where
E: std::fmt::Debug + std::fmt::Display,
Expand Down
Loading
Loading