feat(blame): add binding and api method for git_blame_buffer (#20)

This commit is contained in:
Aleksey Kulikov 2021-12-20 15:03:31 +03:00 committed by GitHub
parent 7148fbf194
commit 39a71811cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 4 deletions

View file

@ -88,6 +88,31 @@ void main() {
expect(() => repo.blame(path: 'invalid'), throwsA(isA<LibGit2Error>()));
});
test('returns blame for buffer', () {
final blame = repo.blame(path: 'feature_file');
expect(blame.length, 2);
final bufferBlame = Blame.buffer(reference: blame, buffer: ' ');
final blameHunk = bufferBlame.first;
expect(bufferBlame.length, 1);
expect(blameHunk.originCommitOid.sha, '0' * 40);
expect(blameHunk.originCommitter, null);
expect(blameHunk.finalCommitOid.sha, '0' * 40);
expect(blameHunk.finalCommitter, null);
bufferBlame.free();
blame.free();
});
test('throws when trying to get blame for empty buffer', () {
final blame = repo.blame(path: 'feature_file');
expect(
() => Blame.buffer(reference: blame, buffer: ''),
throwsA(isA<LibGit2Error>()),
);
blame.free();
});
test(
'successfully gets the blame for provided file with '
'minMatchCharacters set', () {