Skip to content

Commit c87ee79

Browse files
committed
store top_commit_time_local inside of BranchInfo
1 parent 0848790 commit c87ee79

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

Cargo.lock

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

asyncgit/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ keywords = ["git"]
1313

1414
[dependencies]
1515
bitflags = "2"
16+
chrono = { version = "0.4", default-features = false, features = ["clock"] }
1617
crossbeam-channel = "0.5"
1718
easy-cast = "0.5"
1819
fuzzy-matcher = "0.3"

asyncgit/src/sync/branch/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::{
1616
CommitSignature,
1717
},
1818
};
19+
use chrono::{DateTime, Local, TimeZone};
1920
use git2::{Branch, BranchType, Repository};
2021
use scopetime::scope_time;
2122
use std::collections::HashSet;
@@ -97,6 +98,8 @@ pub struct BranchInfo {
9798
///
9899
pub top_commit_time: i64,
99100
///
101+
pub top_commit_time_local: Option<DateTime<Local>>,
102+
///
100103
pub top_commit_author: String,
101104
///
102105
pub details: BranchDetails,
@@ -198,6 +201,9 @@ pub fn get_branches_info(
198201
)?,
199202
top_commit: top_commit.id().into(),
200203
top_commit_time: top_commit.time().seconds(),
204+
top_commit_time_local: Local
205+
.timestamp_opt(top_commit.time().seconds(), 0)
206+
.earliest(),
201207
top_commit_author: author.name,
202208
details,
203209
})

src/popups/branchlist.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use asyncgit::{
2626
},
2727
AsyncGitNotification,
2828
};
29-
use chrono::{Local, TimeZone};
3029
use crossterm::event::{Event, KeyEvent};
3130
use ratatui::{
3231
layout::{
@@ -706,11 +705,10 @@ impl BranchListPopup {
706705
.take(height)
707706
.enumerate()
708707
{
709-
let date_text = Local
710-
.timestamp_opt(displaybranch.top_commit_time, 0)
711-
.earliest()
712-
.map_or("????-??-?? ".to_string(), |date| {
713-
date.date_naive().to_string() + " "
708+
let date_text = displaybranch
709+
.top_commit_time_local
710+
.map_or("????-??-?? ".to_string(), |time| {
711+
time.date_naive().to_string() + " "
714712
});
715713
let author_text =
716714
displaybranch.top_commit_author.clone() + " ";

0 commit comments

Comments
 (0)