aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-22 21:18:03 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-22 21:18:03 -0600
commitabaa66ee80ef6b7bd6bc9694e363c04dc43fcf0f (patch)
tree7c25b35bbc731def241e120c3cf956f0c292f9c2
parent66a0f6cb6592eedc6c357f3bb02840dc93e7d05d (diff)
downloadgityeet-abaa66ee80ef6b7bd6bc9694e363c04dc43fcf0f.tar.gz
gityeet-abaa66ee80ef6b7bd6bc9694e363c04dc43fcf0f.zip
sort by newest commit
-rw-r--r--src/state.rs9
1 files changed, 8 insertions, 1 deletions
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<Path>) -> Result<Vec<Repository>> {
impl State {
pub async fn discover(root: impl AsRef<Path>) -> Result<Self> {
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 })
}