From 35537c66888e799f2bf993844e0671e29be91df1 Mon Sep 17 00:00:00 2001 From: Hubert Date: Sun, 18 Jul 2021 21:13:04 +0200 Subject: [PATCH] save --- src/gitrepo.rs | 6 +++--- templates/git.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gitrepo.rs b/src/gitrepo.rs index 4c934ff..0f3ea8d 100644 --- a/src/gitrepo.rs +++ b/src/gitrepo.rs @@ -6,7 +6,7 @@ use crate::git::GitBrowseEntry; use crate::gitcommit::GitRef; use crate::gitdir::GitDir; use crate::gitfile::GitFile; -use std::path::PathBuf; +use std::path::{PathBuf, Path}; use std::str::FromStr; pub struct GitRepo { @@ -19,12 +19,11 @@ impl GitRepo { Repository::open(path).map(|git2| GitRepo{git2}) } - pub fn get_root_tree<'a, 'b> (&'a self, commit : &'b GitRef) -> Result, git2::Error> { + pub fn get_root_tree<'a, 'b> (&'a self, commit : &'b GitRef, path : &Path) -> Result, git2::Error> { let commit = match commit { GitRef::Commit(commit) => { let oid = Oid::from_str(commit.as_str())?; self.git2.find_commit(oid)? - } GitRef::Branch(branch) => { let branch = self.git2.find_branch(branch.as_str(), BranchType::Local)?; @@ -36,6 +35,7 @@ impl GitRepo { } }; let tree = commit.tree()?; + tree.get_path(path)?. let fullname = PathBuf::from("/"); Ok(GitDir { fullname, tree }) } diff --git a/templates/git.html b/templates/git.html index 031cfd1..c09b821 100644 --- a/templates/git.html +++ b/templates/git.html @@ -79,7 +79,7 @@ {% when Entry::Dir with (name) %}
  • {{ name }}
  • {% when Entry::File with (name) %} -
  • {{ name }}
  • +
  • {{ name }}
  • {% endmatch %} {% endfor %}