clean up
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s
Rust / build (macos-latest, stable) (pull_request) Canceled after 0s
Rust / build (ubuntu-latest, stable) (pull_request) Canceled after 0s
Rust / build (windows-latest, stable) (pull_request) Canceled after 0s

This commit is contained in:
2026-11-12 10:36:53 +07:00
parent 4a871e417a
commit a27eca45c8
26 changed files with 1566 additions and 1352 deletions
+88 -16
View File
@@ -1,5 +1,12 @@
use gpui::SharedString;
use signed_core::RepoStatus;
use std::path::PathBuf;
use gpui::{SharedString, WeakEntity};
use gpui_native_kit::menu::MenuItem;
use nostr::prelude::PublicKey;
use signed_core::{Announcement, RepoAddr, RepoStatus};
use utils::middle_truncate;
use super::NewPullRequestView;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PullRequestFilter {
@@ -32,20 +39,6 @@ impl PullRequestFilter {
}
}
pub fn pr_label(repo_name: &SharedString, pr_id: &str) -> SharedString {
if repo_name.is_empty() {
SharedString::from(pr_id)
} else {
SharedString::from(format!("{repo_name}/{pr_id}"))
}
}
use std::path::PathBuf;
use nostr::prelude::PublicKey;
use signed_core::Announcement;
use utils::middle_truncate;
pub struct ForkCompare {
pub announcement: Announcement,
pub namespace: String,
@@ -62,6 +55,14 @@ impl ForkCompare {
}
}
pub fn pr_label(repo_name: &SharedString, pr_id: &str) -> SharedString {
if repo_name.is_empty() {
SharedString::from(pr_id)
} else {
SharedString::from(format!("{repo_name}/{pr_id}"))
}
}
pub fn fork_display_name(announcement: &Announcement) -> SharedString {
announcement
.name
@@ -77,3 +78,74 @@ pub fn shorten_owner(owner: &PublicKey) -> String {
pub fn truncate_label(label: &str) -> SharedString {
SharedString::from(middle_truncate(label, 18, 0))
}
pub fn source_menu_items(
view: WeakEntity<NewPullRequestView>,
associated: Vec<PathBuf>,
active_path: Option<PathBuf>,
candidates: Vec<Announcement>,
user: Option<PublicKey>,
active_fork: Option<RepoAddr>,
) -> Vec<MenuItem> {
let mut items = Vec::new();
for path in associated {
let label = path
.file_name()
.map(|name| name.to_string_lossy().into_owned())
.unwrap_or_else(|| path.display().to_string());
let target = view.clone();
let path_for_action = path.clone();
items.push(
MenuItem::new(truncate_label(&label))
.checked(active_path.as_ref() == Some(&path))
.handler(move |window, cx| {
let path = path_for_action.clone();
if let Err(error) =
target.update(cx, |this, cx| this.apply_folder_path(path, window, cx))
{
log::warn!("failed to apply checkout: {error}");
}
}),
);
}
let folder_view = view.clone();
items.push(
MenuItem::new("Choose another folder…").handler(move |window, cx| {
if let Err(error) = folder_view.update(cx, |this, cx| this.choose_checkout(window, cx))
{
log::warn!("failed to choose checkout: {error}");
}
}),
);
items.push(MenuItem::separator());
if candidates.is_empty() {
items.push(MenuItem::new("No announced forks of this repository").disabled(true));
} else {
for candidate in candidates {
let subtitle = if Some(candidate.owner) == user {
SharedString::from("Your fork")
} else {
SharedString::from(format!("by {}", shorten_owner(&candidate.owner)))
};
let title = format!("{} — {}", fork_display_name(&candidate), subtitle);
let target = view.clone();
let checked = active_fork == Some(candidate.addr());
let announcement = candidate;
items.push(
MenuItem::new(truncate_label(&title))
.checked(checked)
.handler(move |window, cx| {
let announcement = announcement.clone();
if let Err(error) =
target.update(cx, |this, cx| this.choose_fork(announcement, window, cx))
{
log::warn!("failed to choose fork: {error}");
}
}),
);
}
}
items
}