aboutsummaryrefslogtreecommitdiff
path: root/src/git/repo.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/git/repo.rs')
-rw-r--r--src/git/repo.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/git/repo.rs b/src/git/repo.rs
new file mode 100644
index 0000000..0d04b0d
--- /dev/null
+++ b/src/git/repo.rs
@@ -0,0 +1,19 @@
+use crate::templ_data::repo::RepoData;
+use git2::{Oid, Repository, Tree};
+
+/// Represents a repo in libgit2
+pub(crate) struct Repo {
+ pub(crate) inner: Repository,
+}
+
+impl Repo {
+ pub(crate) fn new(path: &str) -> Self {
+ Self {
+ inner: Repository::open(path).expect(&format!("`{}` is not a valid git repo", path)),
+ }
+ }
+}
+
+pub(crate) fn get_tree<'r>(repo: &'r Repository, rev: &str) -> Tree<'r> {
+ repo.revparse_single(rev).unwrap().peel_to_tree().unwrap()
+}