mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-09-11 12:25:42 +03:00
make sure session/wd git-tree only contains wd files
This commit is contained in:
parent
fb7522463a
commit
711c10ee25
@ -522,6 +522,11 @@ pub fn list_files(
|
||||
if "wd".eq(entry_path.to_str().unwrap()) {
|
||||
return git2::TreeWalkResult::Ok;
|
||||
}
|
||||
|
||||
if entry.kind() == Some(git2::ObjectType::Tree) {
|
||||
return git2::TreeWalkResult::Ok;
|
||||
}
|
||||
|
||||
let blob = entry.to_object(repo).and_then(|obj| obj.peel_to_blob());
|
||||
let content = blob.map(|blob| blob.content().to_vec());
|
||||
|
||||
@ -707,7 +712,9 @@ fn build_wd_tree(repo: &git2::Repository, project: &projects::Project) -> Result
|
||||
// and the session files
|
||||
let commit = reference.peel_to_commit()?;
|
||||
let tree = commit.tree()?;
|
||||
wd_index.read_tree(&tree)?;
|
||||
let wd_tree_entry = tree.get_name("wd").unwrap();
|
||||
let wd_tree = repo.find_tree(wd_tree_entry.id())?;
|
||||
wd_index.read_tree(&wd_tree)?;
|
||||
|
||||
let session_wd_files = fs::list_files(project.wd_path()).with_context(|| {
|
||||
format!("failed to list files in {}", project.wd_path().display())
|
||||
|
@ -158,6 +158,11 @@ fn test_flow() {
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
if i == 0 {
|
||||
assert_eq!(files.len(), 0);
|
||||
} else {
|
||||
assert_eq!(files.len(), 1);
|
||||
}
|
||||
|
||||
let base_file = files.get(&relative_file_path.to_str().unwrap().to_string());
|
||||
let mut text: Vec<char> = match base_file {
|
||||
|
Loading…
Reference in New Issue
Block a user