From abaa66ee80ef6b7bd6bc9694e363c04dc43fcf0f Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 22 Apr 2021 21:18:03 -0600 Subject: sort by newest commit --- src/state.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/state.rs b/src/state.rs index 9a2488b..7c33086 100644 --- a/src/state.rs +++ b/src/state.rs @@ -42,7 +42,14 @@ fn find_repos_in(dir: impl AsRef) -> Result> { impl State { pub async fn discover(root: impl AsRef) -> Result { let root = root.as_ref(); - let data = find_repos_in(root)?; + 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() + }); Ok(Self { root: root.to_owned(), data }) } -- cgit v1.2.3