aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-22 21:28:06 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-22 21:28:06 -0600
commit518025bee1982bad954e3640b693f1a0a747adc0 (patch)
tree33fcec49b613b1adffe8d7db6f0a17cdab5910ff
parentabaa66ee80ef6b7bd6bc9694e363c04dc43fcf0f (diff)
downloadgityeet-518025bee1982bad954e3640b693f1a0a747adc0.tar.gz
gityeet-518025bee1982bad954e3640b693f1a0a747adc0.zip
correctly sort by newest commit
-rw-r--r--src/state.rs14
1 files changed, 9 insertions, 5 deletions
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 })
}