save
This commit is contained in:
parent
aa656d3a19
commit
35537c6688
|
@ -6,7 +6,7 @@ use crate::git::GitBrowseEntry;
|
||||||
use crate::gitcommit::GitRef;
|
use crate::gitcommit::GitRef;
|
||||||
use crate::gitdir::GitDir;
|
use crate::gitdir::GitDir;
|
||||||
use crate::gitfile::GitFile;
|
use crate::gitfile::GitFile;
|
||||||
use std::path::PathBuf;
|
use std::path::{PathBuf, Path};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
pub struct GitRepo {
|
pub struct GitRepo {
|
||||||
|
@ -19,12 +19,11 @@ impl GitRepo {
|
||||||
Repository::open(path).map(|git2| GitRepo{git2})
|
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 {
|
let commit = match commit {
|
||||||
GitRef::Commit(commit) => {
|
GitRef::Commit(commit) => {
|
||||||
let oid = Oid::from_str(commit.as_str())?;
|
let oid = Oid::from_str(commit.as_str())?;
|
||||||
self.git2.find_commit(oid)?
|
self.git2.find_commit(oid)?
|
||||||
|
|
||||||
}
|
}
|
||||||
GitRef::Branch(branch) => {
|
GitRef::Branch(branch) => {
|
||||||
let branch = self.git2.find_branch(branch.as_str(), BranchType::Local)?;
|
let branch = self.git2.find_branch(branch.as_str(), BranchType::Local)?;
|
||||||
|
@ -36,6 +35,7 @@ impl GitRepo {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let tree = commit.tree()?;
|
let tree = commit.tree()?;
|
||||||
|
tree.get_path(path)?.
|
||||||
let fullname = PathBuf::from("/");
|
let fullname = PathBuf::from("/");
|
||||||
Ok(GitDir { fullname, tree })
|
Ok(GitDir { fullname, tree })
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
{% when Entry::Dir with (name) %}
|
{% when Entry::Dir with (name) %}
|
||||||
<li><i class="fa fa-folder"></i> {{ name }}</li>
|
<li><i class="fa fa-folder"></i> {{ name }}</li>
|
||||||
{% when Entry::File with (name) %}
|
{% when Entry::File with (name) %}
|
||||||
<li><i class="fa fa-folder"></i> {{ name }}</li>
|
<li><i class="fa fa-file"></i> {{ name }}</li>
|
||||||
{% endmatch %}
|
{% endmatch %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in New Issue