aboutsummaryrefslogtreecommitdiff
path: root/src/git/repo.rs
blob: 0d04b0d07be61a5d9b84e146e92088b9b84f7b36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()
}