diff --git a/src/main.rs b/src/main.rs index 672908f..ad67c21 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,21 @@ use git2::Repository; fn main() -> eyre::Result<()> { - let repo = Repository::open(".")?; + let repo = Repository::open(".git")?; let mut revwalk = repo.revwalk()?; revwalk.set_sorting(git2::Sort::TIME)?; + let revspec = repo.revparse("HEAD")?; + let from = revspec.from().ok_or(eyre::anyhow!("could not get HEAD"))?; + revwalk.push(from.id())?; + for rev in revwalk.enumerate() { - println!("rev: {})", rev.1?.to_string()) + let oid = rev.1?; + let commit = repo.find_commit(oid)?; + let message = commit + .message() + .ok_or(eyre::anyhow!("could not find message from commit"))?; + println!("rev: {}", message) } Ok(())