mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
feat(diff): add ability to apply diff
This commit is contained in:
parent
344dba60e9
commit
cd9f38c2bd
4 changed files with 89 additions and 0 deletions
|
@ -194,6 +194,22 @@ index e69de29..c217c63 100644
|
|||
diff.free();
|
||||
});
|
||||
|
||||
test(
|
||||
'checks if diff can be applied to repository and successfully applies it',
|
||||
() {
|
||||
final diff = Diff.parse(patchText);
|
||||
final file = File('${tmpDir}subdir/modified_file');
|
||||
|
||||
repo.reset('a763aa560953e7cfb87ccbc2f536d665aa4dff22', GitReset.hard);
|
||||
expect(file.readAsStringSync(), '');
|
||||
|
||||
expect(repo.applies(diff), true);
|
||||
repo.apply(diff);
|
||||
expect(file.readAsStringSync(), 'Modified content\n');
|
||||
|
||||
diff.free();
|
||||
});
|
||||
|
||||
test('successfully creates patch from entry index in diff', () {
|
||||
final diff = Diff.parse(patchText);
|
||||
final patch = Patch.fromDiff(diff, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue