Resolve conflicts

This commit is contained in:
MrSubidubi 2025-08-13 13:05:31 +02:00
commit 3b611313e1
524 changed files with 15162 additions and 3736 deletions

View file

@ -473,7 +473,7 @@ impl PickerDelegate for BranchListDelegate {
&& entry.is_new
{
Some(
IconButton::new("branch-from-default", IconName::GitBranchSmall)
IconButton::new("branch-from-default", IconName::GitBranchAlt)
.on_click(cx.listener(move |this, _, window, cx| {
this.delegate.set_selected_index(ix, window, cx);
this.delegate.confirm(true, window, cx);

View file

@ -272,7 +272,7 @@ impl CommitModal {
.child(
div()
.px_1()
.child(Icon::new(IconName::ChevronDownSmall).size(IconSize::XSmall)),
.child(Icon::new(IconName::ChevronDown).size(IconSize::XSmall)),
),
)
.menu({

View file

@ -1918,6 +1918,99 @@ impl GitPanel {
.detach_and_log_err(cx);
}
pub(crate) fn git_clone(&mut self, repo: String, window: &mut Window, cx: &mut Context<Self>) {
let path = cx.prompt_for_paths(gpui::PathPromptOptions {
files: false,
directories: true,
multiple: false,
});
let workspace = self.workspace.clone();
cx.spawn_in(window, async move |this, cx| {
let mut paths = path.await.ok()?.ok()??;
let mut path = paths.pop()?;
let repo_name = repo
.split(std::path::MAIN_SEPARATOR_STR)
.last()?
.strip_suffix(".git")?
.to_owned();
let fs = this.read_with(cx, |this, _| this.fs.clone()).ok()?;
let prompt_answer = match fs.git_clone(&repo, path.as_path()).await {
Ok(_) => cx.update(|window, cx| {
window.prompt(
PromptLevel::Info,
&format!("Git Clone: {}", repo_name),
None,
&["Add repo to project", "Open repo in new project"],
cx,
)
}),
Err(e) => {
this.update(cx, |this: &mut GitPanel, cx| {
let toast = StatusToast::new(e.to_string(), cx, |this, _| {
this.icon(ToastIcon::new(IconName::XCircle).color(Color::Error))
.dismiss_button(true)
});
this.workspace
.update(cx, |workspace, cx| {
workspace.toggle_status_toast(toast, cx);
})
.ok();
})
.ok()?;
return None;
}
}
.ok()?;
path.push(repo_name);
match prompt_answer.await.ok()? {
0 => {
workspace
.update(cx, |workspace, cx| {
workspace
.project()
.update(cx, |project, cx| {
project.create_worktree(path.as_path(), true, cx)
})
.detach();
})
.ok();
}
1 => {
workspace
.update(cx, move |workspace, cx| {
workspace::open_new(
Default::default(),
workspace.app_state().clone(),
cx,
move |workspace, _, cx| {
cx.activate(true);
workspace
.project()
.update(cx, |project, cx| {
project.create_worktree(&path, true, cx)
})
.detach();
},
)
.detach();
})
.ok();
}
_ => {}
}
Some(())
})
.detach();
}
pub(crate) fn git_init(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let worktrees = self
.project
@ -2736,10 +2829,10 @@ impl GitPanel {
use remote_output::SuccessStyle::*;
match style {
Toast { .. } => {
this.icon(ToastIcon::new(IconName::GitBranchSmall).color(Color::Muted))
this.icon(ToastIcon::new(IconName::GitBranchAlt).color(Color::Muted))
}
ToastWithLog { output } => this
.icon(ToastIcon::new(IconName::GitBranchSmall).color(Color::Muted))
.icon(ToastIcon::new(IconName::GitBranchAlt).color(Color::Muted))
.action("View Log", move |window, cx| {
let output = output.clone();
let output =
@ -2751,7 +2844,7 @@ impl GitPanel {
.ok();
}),
PushPrLink { text, link } => this
.icon(ToastIcon::new(IconName::GitBranchSmall).color(Color::Muted))
.icon(ToastIcon::new(IconName::GitBranchAlt).color(Color::Muted))
.action(text, move |_, cx| cx.open_url(&link)),
}
});
@ -2945,7 +3038,7 @@ impl GitPanel {
.justify_center()
.border_l_1()
.border_color(cx.theme().colors().border)
.child(Icon::new(IconName::ChevronDownSmall).size(IconSize::XSmall)),
.child(Icon::new(IconName::ChevronDown).size(IconSize::XSmall)),
),
)
.menu({
@ -4200,7 +4293,7 @@ impl Panel for GitPanel {
}
fn icon(&self, _: &Window, cx: &App) -> Option<ui::IconName> {
Some(ui::IconName::GitBranchSmall).filter(|_| GitPanelSettings::get_global(cx).button)
Some(ui::IconName::GitBranchAlt).filter(|_| GitPanelSettings::get_global(cx).button)
}
fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> {
@ -4447,7 +4540,7 @@ impl RenderOnce for PanelRepoFooter {
.items_center()
.child(
div().child(
Icon::new(IconName::GitBranchSmall)
Icon::new(IconName::GitBranchAlt)
.size(IconSize::Small)
.color(if single_repo {
Color::Disabled

View file

@ -3,21 +3,25 @@ use std::any::Any;
use ::settings::Settings;
use command_palette_hooks::CommandPaletteFilter;
use commit_modal::CommitModal;
use editor::{Editor, actions::DiffClipboardWithSelectionData};
use editor::{Editor, EditorElement, EditorStyle, actions::DiffClipboardWithSelectionData};
mod blame_ui;
use git::{
repository::{Branch, Upstream, UpstreamTracking, UpstreamTrackingStatus},
status::{FileStatus, StatusCode, UnmergedStatus, UnmergedStatusCode},
};
use git_panel_settings::GitPanelSettings;
use gpui::{Action, App, Context, FocusHandle, Window, actions};
use gpui::{
Action, App, Context, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, TextStyle,
Window, actions,
};
use onboarding::GitOnboardingModal;
use project_diff::ProjectDiff;
use theme::ThemeSettings;
use ui::prelude::*;
use workspace::Workspace;
use workspace::{ModalView, Workspace};
use zed_actions;
use crate::text_diff_view::TextDiffView;
use crate::{git_panel::GitPanel, text_diff_view::TextDiffView};
mod askpass_modal;
pub mod branch_picker;
@ -169,6 +173,15 @@ pub fn init(cx: &mut App) {
panel.git_init(window, cx);
});
});
workspace.register_action(|workspace, _action: &git::Clone, window, cx| {
let Some(panel) = workspace.panel::<git_panel::GitPanel>(cx) else {
return;
};
workspace.toggle_modal(window, cx, |window, cx| {
GitCloneModal::show(panel, window, cx)
});
});
workspace.register_action(|workspace, _: &git::OpenModifiedFiles, window, cx| {
open_modified_files(workspace, window, cx);
});
@ -356,7 +369,7 @@ mod remote_button {
"Publish",
0,
0,
Some(IconName::ArrowUpFromLine),
Some(IconName::ExpandUp),
keybinding_target.clone(),
move |_, window, cx| {
window.dispatch_action(Box::new(git::Push), cx);
@ -383,7 +396,7 @@ mod remote_button {
"Republish",
0,
0,
Some(IconName::ArrowUpFromLine),
Some(IconName::ExpandUp),
keybinding_target.clone(),
move |_, window, cx| {
window.dispatch_action(Box::new(git::Push), cx);
@ -438,7 +451,7 @@ mod remote_button {
.child(
div()
.px_1()
.child(Icon::new(IconName::ChevronDownSmall).size(IconSize::XSmall)),
.child(Icon::new(IconName::ChevronDown).size(IconSize::XSmall)),
),
)
.menu(move |window, cx| {
@ -613,3 +626,98 @@ impl Component for GitStatusIcon {
)
}
}
struct GitCloneModal {
panel: Entity<GitPanel>,
repo_input: Entity<Editor>,
focus_handle: FocusHandle,
}
impl GitCloneModal {
pub fn show(panel: Entity<GitPanel>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let repo_input = cx.new(|cx| {
let mut editor = Editor::single_line(window, cx);
editor.set_placeholder_text("Enter repository", cx);
editor
});
let focus_handle = repo_input.focus_handle(cx);
window.focus(&focus_handle);
Self {
panel,
repo_input,
focus_handle,
}
}
fn render_editor(&self, window: &Window, cx: &App) -> impl IntoElement {
let settings = ThemeSettings::get_global(cx);
let theme = cx.theme();
let text_style = TextStyle {
color: cx.theme().colors().text,
font_family: settings.buffer_font.family.clone(),
font_features: settings.buffer_font.features.clone(),
font_size: settings.buffer_font_size(cx).into(),
font_weight: settings.buffer_font.weight,
line_height: relative(settings.buffer_line_height.value()),
background_color: Some(theme.colors().editor_background),
..Default::default()
};
let element = EditorElement::new(
&self.repo_input,
EditorStyle {
background: theme.colors().editor_background,
local_player: theme.players().local(),
text: text_style,
..Default::default()
},
);
div()
.rounded_md()
.p_1()
.border_1()
.border_color(theme.colors().border_variant)
.when(
self.repo_input
.focus_handle(cx)
.contains_focused(window, cx),
|this| this.border_color(theme.colors().border_focused),
)
.child(element)
.bg(theme.colors().editor_background)
}
}
impl Focusable for GitCloneModal {
fn focus_handle(&self, _: &App) -> FocusHandle {
self.focus_handle.clone()
}
}
impl Render for GitCloneModal {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
div()
.size_full()
.w(rems(34.))
.elevation_3(cx)
.child(self.render_editor(window, cx))
.on_action(cx.listener(|_, _: &menu::Cancel, _, cx| {
cx.emit(DismissEvent);
}))
.on_action(cx.listener(|this, _: &menu::Confirm, window, cx| {
let repo = this.repo_input.read(cx).text(cx);
this.panel.update(cx, |panel, cx| {
panel.git_clone(repo, window, cx);
});
cx.emit(DismissEvent);
}))
}
}
impl EventEmitter<DismissEvent> for GitCloneModal {}
impl ModalView for GitCloneModal {}

View file

@ -110,7 +110,7 @@ impl Render for GitOnboardingModal {
.child(Headline::new("Native Git Support").size(HeadlineSize::Large)),
)
.child(h_flex().absolute().top_2().right_2().child(
IconButton::new("cancel", IconName::X).on_click(cx.listener(
IconButton::new("cancel", IconName::Close).on_click(cx.listener(
|_, _: &ClickEvent, _window, cx| {
git_onboarding_event!("Cancelled", trigger = "X click");
cx.emit(DismissEvent);