feat(diff): add binding and API method for git_diff_tree_to_workdir_with_index (#23)

This commit is contained in:
Aleksey Kulikov 2021-12-21 12:34:52 +03:00 committed by GitHub
parent 5740831bb9
commit 561986ebfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 107 additions and 0 deletions

View file

@ -56,6 +56,20 @@ void main() {
'subdir/modified_file',
];
const treeToWorkdirWithIndex = [
'file_deleted',
'modified_file',
'staged_changes',
'staged_changes_file_deleted',
'staged_changes_file_modified',
'staged_delete',
'staged_delete_file_modified',
'staged_new',
'staged_new_file_modified',
'subdir/deleted_file',
'subdir/modified_file',
];
const patchText = """
diff --git a/subdir/modified_file b/subdir/modified_file
index e69de29..c217c63 100644
@ -205,6 +219,23 @@ index e69de29..c217c63 100644
tree.free();
});
test('returns diff between tree and workdir with index', () {
final head = repo.head;
final commit = repo.lookupCommit(head.target);
final tree = commit.tree;
final diff = Diff.treeToWorkdirWithIndex(repo: repo, tree: tree);
expect(diff.length, 11);
for (var i = 0; i < diff.deltas.length; i++) {
expect(diff.deltas[i].newFile.path, treeToWorkdirWithIndex[i]);
}
diff.free();
tree.free();
commit.free();
head.free();
});
test('successfully merges diffs', () {
final head = repo.head;
final commit = repo.lookupCommit(head.target);