This commit is contained in:
Hubert 2021-07-15 07:08:39 +02:00
parent 7fbd18047e
commit 8a0b525649
2 changed files with 18 additions and 0 deletions

View File

@ -18,3 +18,4 @@ env_logger = "0.8.4"
serde = "1.0.126"
futures = "0.3.15"
tokio = {version = "0.2.25", features = ["time", "process", "io-util"]}
git2 = "0.13.20"

View File

@ -35,6 +35,7 @@ use actix_web::client::PayloadError;
use crate::reader::ToStream;
use crate::writer::Writer;
use crate::gitust::Gitust;
use git2::{Reference, Commit, Tree};
#[derive(Template)]
#[template(path = "hello.html")]
@ -152,6 +153,22 @@ async fn git_main(
let owner = Owner { name : owner};
let repo = Repository {name : reponame, owner};
let user = User { name : "Hubert".to_string()};
let repogit = match git2::Repository::open(format!("{}/{}/{}.git", &gitust.repo_root_path, &repo.owner.name, &repo.name)) {
Ok(repo) => repo,
Err(e) => panic!("failed to open: {}", e),
};
let head = match repogit.head() {
Ok(head) => head,
Err(e) => panic!("failed to get head: {}", e)
};
let commit = match head.peel_to_commit() {
Ok(commit) => commit,
Err(e) => panic!("failed to get commit: {}", e)
};
let tree = match commit.tree() {
Ok(tree) => tree,
Err(e) => panic!("failed to get tree: {}", e)
};
GitMainTemplate { repo, browse : browse, root : path, user_opt : Some(user)}
}
//#[get("/git/{owner}/{repo}.git/{path:.*}")]