From 518025bee1982bad954e3640b693f1a0a747adc0 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 22 Apr 2021 21:28:06 -0600 Subject: correctly sort by newest commit --- src/state.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/state.rs b/src/state.rs index 7c33086..004d3e2 100644 --- a/src/state.rs +++ b/src/state.rs @@ -44,12 +44,16 @@ impl State { let root = root.as_ref(); let mut data = find_repos_in(root)?; data.sort_by_key(|repo| { - let mut revwalk = repo.revwalk().expect("revwalk failed?"); - revwalk.set_sorting(git2::Sort::TIME).expect("bruh"); - revwalk - .map(|commit| repo.find_commit(commit.expect("yeet")).expect("sdfji").time()) - .max() + let mut last_update = git2::Time::new(0, 0); + repo.odb().expect("no object database").foreach(|oid| { + if let Ok(commit) = repo.find_commit(oid.clone()) { + last_update = last_update.max(commit.time()); + } + true + }).expect("foreach failed"); + last_update }); + data.reverse(); Ok(Self { root: root.to_owned(), data }) } -- cgit v1.2.3