mirror of
https://forge.pointfixe.fr/hubert/gitust.git
synced 2026-02-04 19:47:29 +01:00
save
This commit is contained in:
@@ -5,7 +5,7 @@ pub struct Error(String);
|
||||
|
||||
impl From<git2::Error> for Error {
|
||||
fn from(giterr: git2::Error) -> Self {
|
||||
Error(giterr.to_string())
|
||||
Error(format!("{}", giterr))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ impl GitRepo {
|
||||
Repository::open(path).map(|git2| GitRepo{git2})
|
||||
}
|
||||
|
||||
pub fn get_root_tree<'a, 'b> (&'a self, commit : &'b GitRef, path : &Path) -> Result<GitDir<'a>, git2::Error> {
|
||||
pub fn get_tree<'a, 'b, 'c> (&'a self, commit : &'b GitRef, path : &'c Path) -> Result<GitDir<'a>, git2::Error> {
|
||||
let commit = match commit {
|
||||
GitRef::Commit(commit) => {
|
||||
let oid = Oid::from_str(commit.as_str())?;
|
||||
@@ -35,9 +35,9 @@ impl GitRepo {
|
||||
}
|
||||
};
|
||||
let tree = commit.tree()?;
|
||||
tree.get_path(path)?.
|
||||
let fullname = PathBuf::from("/");
|
||||
Ok(GitDir { fullname, tree })
|
||||
let subtree = self.git2.find_tree(tree.get_path(path)?.id())?;
|
||||
let fullname = path.to_path_buf();
|
||||
Ok(GitDir { fullname, tree : subtree })
|
||||
}
|
||||
|
||||
pub async fn browse<'a>(&'a self, dir: &GitDir<'a>) -> Result<Vec<GitBrowseEntry<'a>>, git2::Error> {
|
||||
|
||||
@@ -172,7 +172,7 @@ async fn git_main(
|
||||
((str_ref.to_string(), href.clone()), href)
|
||||
}).collect();
|
||||
let gitrepo = GitRepo::new(format!("{}/{}/{}.git", &gitust.repo_root_path, &repo.owner.name, &repo.name).as_str())?;
|
||||
let root = gitrepo.get_root_tree(&commit)?;
|
||||
let root = gitrepo.get_tree(&commit, Path::new(rootname.as_str()))?;
|
||||
let browse = gitrepo.browse(&root).await?;
|
||||
let mut entries : Vec<Entry> = Vec::new();
|
||||
for entry in browse {
|
||||
|
||||
Reference in New Issue
Block a user