Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

git_ui: Add git init button to empty repository state (#49203)

Xiaobo Liu909c147b4bf1
diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs
index 50b29381fba..d50f9088211 100644
--- a/crates/git_ui/src/git_panel.rs
+++ b/crates/git_ui/src/git_panel.rs
@@ -228,6 +228,11 @@ pub fn register(workspace: &mut Workspace) {
workspace.register_action(|workspace, _: &ExpandCommitEditor, window, cx| {
CommitModal::toggle(workspace, None, window, cx)
});
+ workspace.register_action(|workspace, _: &git::Init, window, cx| {
+ if let Some(panel) = workspace.panel::<GitPanel>(cx) {
+ panel.update(cx, |panel, cx| panel.git_init(window, cx));
+ }
+ });
}
#[derive(Debug, Clone)]
diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs
index 7c460d5f891..9b6277285ab 100644
--- a/crates/git_ui/src/project_diff.rs
+++ b/crates/git_ui/src/project_diff.rs
@@ -1671,9 +1671,12 @@ impl RenderOnce for ProjectDiffEmptyState {
v_flex()
.gap_1()
.when(self.no_repo, |this| {
- // TODO: add git init
this.text_center()
.child(Label::new("No Repository").color(Color::Muted))
+ .child(
+ Button::new("initialize-repo", "Initialize Repository")
+ .on_click(move |_, _, cx| cx.dispatch_action(&git::Init)),
+ )
})
.map(|this| {
if not_ahead_or_behind && self.current_branch.is_some() {