mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
feat(diff): return list of patches
This commit is contained in:
parent
677457279d
commit
6845286af2
2 changed files with 25 additions and 0 deletions
|
@ -40,6 +40,16 @@ class Diff {
|
|||
return deltas;
|
||||
}
|
||||
|
||||
/// Returns a list of [Patch]es.
|
||||
List<Patch> get patches {
|
||||
final length = bindings.length(_diffPointer);
|
||||
var patches = <Patch>[];
|
||||
for (var i = 0; i < length; i++) {
|
||||
patches.add(Patch.fromDiff(this, i));
|
||||
}
|
||||
return patches;
|
||||
}
|
||||
|
||||
/// Returns a patch diff string.
|
||||
String get patch {
|
||||
final length = bindings.length(_diffPointer);
|
||||
|
|
|
@ -281,6 +281,21 @@ index e69de29..c217c63 100644
|
|||
index.free();
|
||||
});
|
||||
|
||||
test('returns deltas', () {
|
||||
final index = repo.index;
|
||||
final diff = index.diffToWorkdir();
|
||||
final patches = diff.patches;
|
||||
|
||||
expect(patches.length, 8);
|
||||
expect(patches.first.delta.status, GitDelta.deleted);
|
||||
|
||||
for (var p in patches) {
|
||||
p.free();
|
||||
}
|
||||
diff.free();
|
||||
index.free();
|
||||
});
|
||||
|
||||
test('returns stats', () {
|
||||
final index = repo.index;
|
||||
final diff = index.diffToWorkdir();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue