From e68aa0dfd1a200ff781f19ddffd69d01d9796ad3 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 16 Sep 2020 01:58:58 +0200 Subject: write_since(): Take an arbitrary branch as input Allow the branch to be parameterised instead of forcing the base to be the local "master" branch. Added the `Todos` struct to store a `Repository` reference, since we need this for both the base ref and the diff. Decided to take a `Tree` instead of a `Branch` because we might want to compare against an arbitrary ref and allow users to specify that ref on the command line. --- src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 60f12d8..48e8f5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,13 @@ #![warn(rust_2018_idioms)] -use git_todo::write_since; +use git2::Repository; + +use git_todo::Todos; fn main() { - write_since(&mut std::io::stdout()); + let repo = Repository::open(".").unwrap(); + + let todos = Todos { repo: &repo }; + todos.write_since(todos.master_tree(), &mut std::io::stdout()); } -- cgit v1.2.3