fix incorrect file names/paths
let obj = repo.revparse_single(rev)?;
let tree = obj.peel_to_tree()?;
for entry in tree.iter() {
- let name = prefix.to_string() + entry.name().unwrap_or_default();
+ let name = entry.name().unwrap_or_default().to_string();
+ let path = prefix.to_string() + entry.name().unwrap_or_default();
let kind = match entry.kind() {
Some(git2::ObjectType::Tree) => "dir",
Some(git2::ObjectType::Blob) => "file",
files.push(GitFile {
id: entry.id().to_string(),
name: name.clone(),
- path: match depth {
- 0 => name.to_string(),
- _ => format!("{}/{}", prefix, name),
- },
+ path: path.clone(),
kind: kind.to_string(),
mode: entry.filemode(),
is_binary,
contents_preformatted: true,
});
if recurse && depth < (max_depth - 1) && entry.kind() == Some(git2::ObjectType::Tree) {
- let prefix = name + "/";
+ let prefix = path + "/";
walk_file_tree(repo, &entry.id().to_string(), files,
depth+1, max_depth, true, &prefix)?;
}