save
This commit is contained in:
parent
aa656d3a19
commit
35537c6688
|
@ -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<GitDir<'a>, git2::Error> {
|
||||
pub fn get_root_tree<'a, 'b> (&'a self, commit : &'b GitRef, path : &Path) -> Result<GitDir<'a>, 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 })
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
{% when Entry::Dir with (name) %}
|
||||
<li><i class="fa fa-folder"></i> {{ name }}</li>
|
||||
{% when Entry::File with (name) %}
|
||||
<li><i class="fa fa-folder"></i> {{ name }}</li>
|
||||
<li><i class="fa fa-file"></i> {{ name }}</li>
|
||||
{% endmatch %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue