From 083ef856968812ef83f6dc2db0cc191c50b83cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Wed, 7 Oct 2026 07:39:01 -0400 Subject: [PATCH] Git: clear CI's lints; a row's drawn parts gather in Entry, the history's tuple is Counted, picking tests sit under tests/ --- src/git/history.rs | 9 +++--- src/git/mod.rs | 2 -- src/git/refs.rs | 46 ++++++++++++++++++------------ src/git/tags.rs | 40 ++++++++++++++------------ src/git/{tests.rs => tests/mod.rs} | 2 ++ src/git/{ => tests}/picking.rs | 2 +- 6 files changed, 56 insertions(+), 45 deletions(-) rename src/git/{tests.rs => tests/mod.rs} (99%) rename src/git/{ => tests}/picking.rs (99%) diff --git a/src/git/history.rs b/src/git/history.rs index 236413f..64fd5e9 100644 --- a/src/git/history.rs +++ b/src/git/history.rs @@ -13,22 +13,21 @@ use crate::{ }; type OnPick = Rc; +/// A commit with lines added and removed, if counted. +pub type Counted = (Commit, Option<(usize, usize)>); /// A file's commits newest first; draws rows in view. #[derive(IntoElement)] pub struct FileHistory { id: ElementId, - commits: Rc)>>, + commits: Rc>, selected: Option, on_pick: Option, } impl FileHistory { /// Each commit with lines added and removed, if counted. - pub fn new( - id: impl Into, - commits: Rc)>>, - ) -> Self { + pub fn new(id: impl Into, commits: Rc>) -> Self { Self { id: id.into(), commits, diff --git a/src/git/mod.rs b/src/git/mod.rs index 37ef3c9..abcfd2c 100644 --- a/src/git/mod.rs +++ b/src/git/mod.rs @@ -7,8 +7,6 @@ mod graph; mod history; mod merge; mod merging; -#[cfg(all(test, feature = "test-support"))] -mod picking; mod refs; mod review; mod rows; diff --git a/src/git/refs.rs b/src/git/refs.rs index 01d321c..f90c6af 100644 --- a/src/git/refs.rs +++ b/src/git/refs.rs @@ -204,17 +204,23 @@ pub(super) struct Pick { pub run: Run, } -/// A row's name, detail, trailing words and hover actions. -pub(super) fn listed( - id: ElementId, - icon: IconName, - name: AnyElement, - detail: SharedString, - trailing: Vec, - actions: Vec, - pick: Option, - cx: &App, -) -> AnyElement { +/// A row's icon, name, detail, trailing words and hover actions. +pub(super) struct Entry { + pub icon: IconName, + pub name: AnyElement, + pub detail: SharedString, + pub trailing: Vec, + pub actions: Vec, +} + +pub(super) fn listed(id: ElementId, entry: Entry, pick: Option, cx: &App) -> AnyElement { + let Entry { + icon, + name, + detail, + trailing, + actions, + } = entry; let theme = cx.theme(); let colors = theme.colors.clone(); div() @@ -406,15 +412,17 @@ impl RenderOnce for BranchList { .collect(); listed( (self.id.clone(), format!("branch-{}", branch.name)).into(), - if branch.current { - IconName::Check - } else { - IconName::GitBranch + Entry { + icon: if branch.current { + IconName::Check + } else { + IconName::GitBranch + }, + name, + detail: branch.subject.clone(), + trailing, + actions, }, - name, - branch.subject.clone(), - trailing, - actions, bind(&self.on_pick).map(|run| Pick { spoken: branch.name.clone(), selected: self.selected.as_ref() == Some(&branch.name), diff --git a/src/git/tags.rs b/src/git/tags.rs index a0488e9..d2a970b 100644 --- a/src/git/tags.rs +++ b/src/git/tags.rs @@ -5,7 +5,7 @@ use gpui::{ Window, div, }; -use super::refs::{OnName, Pick, Run, action, listed}; +use super::refs::{Entry, OnName, Pick, Run, action, listed}; use crate::{ i18n, primitives::IconName, @@ -70,14 +70,16 @@ impl RenderOnce for TagList { let short: String = tag.commit.chars().take(7).collect(); listed( (self.id.clone(), format!("tag-{}", tag.name)).into(), - IconName::Tag, - div() - .text_color(colors.fg) - .child(tag.name.clone()) - .into_any_element(), - tag.message.clone().unwrap_or_default(), - vec![short.into(), tag.when.clone()], - Vec::new(), + Entry { + icon: IconName::Tag, + name: div() + .text_color(colors.fg) + .child(tag.name.clone()) + .into_any_element(), + detail: tag.message.clone().unwrap_or_default(), + trailing: vec![short.into(), tag.when.clone()], + actions: Vec::new(), + }, self.on_pick.clone().map(|pick| { let name = tag.name.clone(); Pick { @@ -197,15 +199,17 @@ impl RenderOnce for StashList { }); listed( (self.id.clone(), format!("stash-{ix}")).into(), - IconName::Archive, - div() - .font_family(theme.mono_family.clone()) - .text_color(colors.fg) - .child(name) - .into_any_element(), - detail, - vec![stash.when.clone()], - actions, + Entry { + icon: IconName::Archive, + name: div() + .font_family(theme.mono_family.clone()) + .text_color(colors.fg) + .child(name) + .into_any_element(), + detail, + trailing: vec![stash.when.clone()], + actions, + }, pick, cx, ) diff --git a/src/git/tests.rs b/src/git/tests/mod.rs similarity index 99% rename from src/git/tests.rs rename to src/git/tests/mod.rs index c0db129..602041f 100644 --- a/src/git/tests.rs +++ b/src/git/tests/mod.rs @@ -4,6 +4,8 @@ use gpui::{ }; use super::DiffViewer; + +mod picking; use crate::{forms, primitives::FocusNext, theme::Theme}; /// A diff whose first stretch folds, and folds asked open. diff --git a/src/git/picking.rs b/src/git/tests/picking.rs similarity index 99% rename from src/git/picking.rs rename to src/git/tests/picking.rs index fe1f90e..440dd18 100644 --- a/src/git/picking.rs +++ b/src/git/tests/picking.rs @@ -7,7 +7,7 @@ use gpui::{ TestAppContext, VisualTestContext, Window, div, px, }; -use super::{ +use crate::git::{ Blame, BlameView, Branch, BranchList, Commit, CommitList, FileHistory, GitTag, Stash, StashList, TagList, };