Skip to content

Commit a5d5b3b

Browse files
author
Stephan Dilly
committed
allow longer messages in log view
1 parent f8294dc commit a5d5b3b

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- introduced proper changelog
1010

1111
### Changed
12+
- show longer commit messages in log view
1213
- introduce propper error handling in `asyncgit` [[@MCord](https://github.com/MCord)] ([#53](https://github.com/extrawurst/gitui/issues/53))
1314
- better error message when trying to run outside of a valid git repo ([#56](https://github.com/extrawurst/gitui/issues/56))
1415
- improve ctrl+c handling so it is checked first and no component needs to worry of blocking it

asyncgit/src/sync/commits_info.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub struct CommitInfo {
2020
pub fn get_commits_info(
2121
repo_path: &str,
2222
ids: &[Oid],
23+
message_length_limit: usize,
2324
) -> Result<Vec<CommitInfo>> {
2425
scope_time!("get_commits_info");
2526

@@ -33,7 +34,7 @@ pub fn get_commits_info(
3334

3435
let res = commits
3536
.map(|c: Commit| {
36-
let message = get_message(&c);
37+
let message = get_message(&c, message_length_limit);
3738
let author = if let Some(name) = c.author().name() {
3839
String::from(name)
3940
} else {
@@ -51,9 +52,9 @@ pub fn get_commits_info(
5152
Ok(res)
5253
}
5354

54-
fn get_message(c: &Commit) -> String {
55+
fn get_message(c: &Commit, message_length_limit: usize) -> String {
5556
if let Some(msg) = c.message() {
56-
limit_str(msg, 50)
57+
limit_str(msg, message_length_limit)
5758
} else {
5859
String::from("<unknown>")
5960
}
@@ -91,7 +92,8 @@ mod tests {
9192
stage_add_file(repo_path, file_path).unwrap();
9293
let c2 = commit(repo_path, "commit2").unwrap();
9394

94-
let res = get_commits_info(repo_path, &vec![c2, c1]).unwrap();
95+
let res =
96+
get_commits_info(repo_path, &vec![c2, c1], 50).unwrap();
9597

9698
assert_eq!(res.len(), 2);
9799
assert_eq!(res[0].message.as_str(), "commit2");

asyncgit/src/sync/logwalker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ mod tests {
9898
let mut walk = LogWalker::new(&repo);
9999
walk.read(&mut items, 100).unwrap();
100100

101-
let info = get_commits_info(repo_path, &items).unwrap();
101+
let info = get_commits_info(repo_path, &items, 50).unwrap();
102102
dbg!(&info);
103103

104104
assert_eq!(items.len(), 2);

src/tabs/revlog/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub struct Revlog {
5454
first_open_done: bool,
5555
scroll_state: (Instant, f32),
5656
tags: Tags,
57-
current_height: u16,
57+
current_size: (u16, u16),
5858
}
5959

6060
impl Revlog {
@@ -69,7 +69,7 @@ impl Revlog {
6969
first_open_done: false,
7070
scroll_state: (Instant::now(), 0_f32),
7171
tags: Tags::new(),
72-
current_height: 0,
72+
current_size: (0, 0),
7373
}
7474
}
7575

@@ -98,6 +98,7 @@ impl Revlog {
9898
let commits = sync::get_commits_info(
9999
CWD,
100100
&self.git_log.get_slice(want_min, SLICE_SIZE).unwrap(),
101+
self.current_size.0.into(),
101102
);
102103

103104
if let Ok(commits) = commits {
@@ -114,7 +115,7 @@ impl Revlog {
114115
.max(1);
115116

116117
let page_offset =
117-
usize::from(self.current_height).saturating_sub(1);
118+
usize::from(self.current_size.1).saturating_sub(1);
118119

119120
self.selection = match scroll {
120121
ScrollType::Up => {
@@ -236,7 +237,10 @@ impl Revlog {
236237

237238
impl DrawableComponent for Revlog {
238239
fn draw<B: Backend>(&mut self, f: &mut Frame<B>, area: Rect) {
239-
self.current_height = area.height.saturating_sub(2);
240+
self.current_size = (
241+
area.width.saturating_sub(2),
242+
area.height.saturating_sub(2),
243+
);
240244

241245
let height = area.height as usize;
242246
let selection =

0 commit comments

Comments
 (0)