mirror of
https://forge.pointfixe.fr/hubert/gitust.git
synced 2026-02-04 16:37:30 +01:00
git init
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -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:.*}")]
|
||||
|
||||
Reference in New Issue
Block a user