Git: clear CI's lints; a row's drawn parts gather in Entry, the history's tuple is Counted, picking tests sit under tests/
This commit is contained in:
1 parent
179ea8e276
commit
083ef85696
6 files changed
+56
-45
No files matched your search
+4
-5
@@ -13,22 +13,21 @@ use crate::{
|
||||
};
|
||||
|
||||
type OnPick = Rc<dyn Fn(&SharedString, &mut Window, &mut App)>;
|
||||
/// 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<Vec<(Commit, Option<(usize, usize)>)>>,
|
||||
commits: Rc<Vec<Counted>>,
|
||||
selected: Option<SharedString>,
|
||||
on_pick: Option<OnPick>,
|
||||
}
|
||||
|
||||
impl FileHistory {
|
||||
/// Each commit with lines added and removed, if counted.
|
||||
pub fn new(
|
||||
id: impl Into<ElementId>,
|
||||
commits: Rc<Vec<(Commit, Option<(usize, usize)>)>>,
|
||||
) -> Self {
|
||||
pub fn new(id: impl Into<ElementId>, commits: Rc<Vec<Counted>>) -> Self {
|
||||
Self {
|
||||
id: id.into(),
|
||||
commits,
|
||||
|
||||
@@ -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;
|
||||
|
||||
+27
-19
@@ -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<SharedString>,
|
||||
actions: Vec<AnyElement>,
|
||||
pick: Option<Pick>,
|
||||
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<SharedString>,
|
||||
pub actions: Vec<AnyElement>,
|
||||
}
|
||||
|
||||
pub(super) fn listed(id: ElementId, entry: Entry, pick: Option<Pick>, 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),
|
||||
|
||||
+22
-18
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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.
|
||||
@@ -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,
|
||||
};
|
||||
Reference in new issue
Block a user