feat(patch): add binding and API method for git_patch_line_stats (#39)

This commit is contained in:
Aleksey Kulikov 2022-01-25 16:34:27 +03:00 committed by GitHub
parent 06cc0230c7
commit 432abffa89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 79 additions and 4 deletions

View file

@ -177,6 +177,31 @@ Map<String, Object> hunk({
return {'hunk': out.value, 'linesN': linesN};
}
/// Get line counts of each type in a patch.
Map<String, int> lineStats(Pointer<git_patch> patch) {
final context = calloc<Uint64>();
final insertions = calloc<Uint64>();
final deletions = calloc<Uint64>();
libgit2.git_patch_line_stats(
context,
insertions,
deletions,
patch,
);
final result = {
'context': context.value,
'insertions': insertions.value,
'deletions': deletions.value,
};
calloc.free(context);
calloc.free(insertions);
calloc.free(deletions);
return result;
}
/// Get data about a line in a hunk of a patch.
Pointer<git_diff_line> lines({
required Pointer<git_patch> patchPointer,