Skip to content

Commit c06b8ea

Browse files
authored
Merge branch 'master' into feature/feedback_copying
2 parents e17ee69 + 5b7686b commit c06b8ea

File tree

5 files changed

+61
-21
lines changed

5 files changed

+61
-21
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
* add `regex-fancy` and `regex-onig` features to allow building Syntect with Onigumara regex engine instead of the default engine based on fancy-regex [[@jirutka](https://github.com/jirutka)]
2424
* add `vendor-openssl` feature to allow building without vendored openssl [[@jirutka](https://github.com/jirutka)]
2525
* allow copying marked commits [[@remique](https://github.com/remique)] ([#1288](https://github.com/extrawurst/gitui/issues/1288))
26-
* Add notification when correctly copying hash commit ([#1160](https://github.com/extrawurst/gitui/issues/1160))
27-
* Add a notification with details when the copy throws an error
26+
* Feedback for success/failure of copying hash commit [[@sergioribera]](https://github.com/sergioribera)([#1160](https://github.com/extrawurst/gitui/issues/1160))
27+
* display tags and branches in the log view [[@alexmaco]](https://github.com/alexmaco)([#1371](https://github.com/extrawurst/gitui/pull/1371))
2828

2929
### Fixes
3030
* remove insecure dependency `ansi_term` ([#1290](https://github.com/extrawurst/gitui/issues/1290))

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/commitlist.rs

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ use crate::{
1111
ui::{calc_scroll_top, draw_scrollbar},
1212
};
1313
use anyhow::Result;
14-
use asyncgit::sync::{CommitId, Tags};
14+
use asyncgit::sync::{BranchInfo, CommitId, Tags};
1515
use chrono::{DateTime, Local};
1616
use crossterm::event::Event;
1717
use itertools::Itertools;
1818
use std::{
19-
borrow::Cow, cell::Cell, cmp, convert::TryFrom, time::Instant,
19+
borrow::Cow, cell::Cell, cmp, collections::BTreeMap,
20+
convert::TryFrom, time::Instant,
2021
};
2122
use tui::{
2223
backend::Backend,
@@ -38,6 +39,7 @@ pub struct CommitList {
3839
marked: Vec<(usize, CommitId)>,
3940
scroll_state: (Instant, f32),
4041
tags: Option<Tags>,
42+
branches: BTreeMap<CommitId, Vec<String>>,
4143
current_size: Cell<(u16, u16)>,
4244
scroll_top: Cell<usize>,
4345
theme: SharedTheme,
@@ -61,6 +63,7 @@ impl CommitList {
6163
count_total: 0,
6264
scroll_state: (Instant::now(), 0_f32),
6365
tags: None,
66+
branches: BTreeMap::default(),
6467
current_size: Cell::new((0, 0)),
6568
scroll_top: Cell::new(0),
6669
theme,
@@ -353,10 +356,12 @@ impl CommitList {
353356
}
354357
}
355358

359+
#[allow(clippy::too_many_arguments)]
356360
fn get_entry_to_add<'a>(
357361
e: &'a LogEntry,
358362
selected: bool,
359363
tags: Option<String>,
364+
branches: Option<String>,
360365
theme: &Theme,
361366
width: usize,
362367
now: DateTime<Local>,
@@ -412,12 +417,18 @@ impl CommitList {
412417
txt.push(splitter.clone());
413418

414419
// commit tags
415-
txt.push(Span::styled(
416-
Cow::from(tags.map_or_else(String::new, |tags| {
417-
format!(" {}", tags)
418-
})),
419-
theme.tags(selected),
420-
));
420+
if let Some(tags) = tags {
421+
txt.push(splitter.clone());
422+
txt.push(Span::styled(tags, theme.tags(selected)));
423+
}
424+
425+
if let Some(branches) = branches {
426+
txt.push(splitter.clone());
427+
txt.push(Span::styled(
428+
branches,
429+
theme.branch(selected, true),
430+
));
431+
}
421432

422433
txt.push(splitter);
423434

@@ -452,9 +463,20 @@ impl CommitList {
452463
{
453464
let tags =
454465
self.tags.as_ref().and_then(|t| t.get(&e.id)).map(
455-
|tags| tags.iter().map(|t| &t.name).join(" "),
466+
|tags| {
467+
tags.iter()
468+
.map(|t| format!("<{}>", t.name))
469+
.join(" ")
470+
},
456471
);
457472

473+
let branches = self.branches.get(&e.id).map(|names| {
474+
names
475+
.iter()
476+
.map(|name| format!("{{{}}}", name))
477+
.join(" ")
478+
});
479+
458480
let marked = if any_marked {
459481
self.is_marked(&e.id)
460482
} else {
@@ -465,6 +487,7 @@ impl CommitList {
465487
e,
466488
idx + self.scroll_top.get() == selection,
467489
tags,
490+
branches,
468491
&self.theme,
469492
width,
470493
now,
@@ -483,6 +506,17 @@ impl CommitList {
483506
pub fn select_entry(&mut self, position: usize) {
484507
self.selection = position;
485508
}
509+
510+
pub fn set_branches(&mut self, branches: Vec<BranchInfo>) {
511+
self.branches.clear();
512+
513+
for b in branches {
514+
self.branches
515+
.entry(b.top_commit)
516+
.or_default()
517+
.push(b.name);
518+
}
519+
}
486520
}
487521

488522
impl DrawableComponent for CommitList {

src/tabs/revlog.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
use anyhow::Result;
1414
use asyncgit::{
1515
cached,
16-
sync::{self, CommitId, RepoPathRef},
16+
sync::{self, get_branches_info, CommitId, RepoPathRef},
1717
AsyncGitNotification, AsyncLog, AsyncTags, CommitFilesParams,
1818
FetchStatus,
1919
};
@@ -108,6 +108,11 @@ impl Revlog {
108108
self.branch_name.lookup().map(Some).unwrap_or(None),
109109
);
110110

111+
self.list.set_branches(get_branches_info(
112+
&self.repo.borrow(),
113+
true,
114+
)?);
115+
111116
if self.commit_details.is_visible() {
112117
let commit = self.selected_commit();
113118
let tags = self.selected_commit_tags(&commit);

src/ui/style.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ pub struct Theme {
3636
danger_fg: Color,
3737
push_gauge_bg: Color,
3838
push_gauge_fg: Color,
39+
tag_fg: Color,
40+
branch_fg: Color,
3941
}
4042

4143
impl Theme {
@@ -64,14 +66,11 @@ impl Theme {
6466
Style::default().add_modifier(Modifier::BOLD)
6567
} else {
6668
Style::default()
67-
};
69+
}
70+
.fg(self.branch_fg);
6871

6972
if selected {
70-
branch.patch(
71-
Style::default()
72-
.fg(self.command_fg)
73-
.bg(self.selection_bg),
74-
)
73+
branch.patch(Style::default().bg(self.selection_bg))
7574
} else {
7675
branch
7776
}
@@ -89,7 +88,7 @@ impl Theme {
8988

9089
pub fn tags(&self, selected: bool) -> Style {
9190
Style::default()
92-
.fg(self.selected_tab)
91+
.fg(self.tag_fg)
9392
.add_modifier(Modifier::BOLD)
9493
.bg(if selected {
9594
self.selection_bg
@@ -325,6 +324,8 @@ impl Default for Theme {
325324
danger_fg: Color::Red,
326325
push_gauge_bg: Color::Blue,
327326
push_gauge_fg: Color::Reset,
327+
tag_fg: Color::LightMagenta,
328+
branch_fg: Color::LightYellow,
328329
}
329330
}
330331
}

0 commit comments

Comments
 (0)