refactor!: use Finalizer to automatically free allocated memory for objects

BREAKING CHANGE: signature change for remote and repository callbacks
during repository clone operation.
This commit is contained in:
Aleksey Kulikov 2022-04-21 14:07:11 +03:00
parent 94c40f9a94
commit b589097c8c
73 changed files with 1073 additions and 1618 deletions

View file

@ -41,11 +41,8 @@ void main() {
contents = file.readAsStringSync();
expect(contents, 'Feature edit\n');
final index = repo.index;
final diff = Diff.indexToWorkdir(repo: repo, index: index);
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
expect(diff.deltas, isEmpty);
index.free();
});
test('resets with mixed', () {
@ -56,37 +53,26 @@ void main() {
contents = file.readAsStringSync();
expect(contents, 'Feature edit\n');
final index = repo.index;
final diff = Diff.indexToWorkdir(repo: repo, index: index);
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
expect(diff.deltas.length, 1);
index.free();
});
group('resetDefault', () {
test('updates entry in the index', () {
file.writeAsStringSync('new edit');
final index = repo.index;
index.add('feature_file');
repo.index.add('feature_file');
expect(repo.status['feature_file'], {GitStatus.indexModified});
final head = repo.head;
repo.resetDefault(oid: head.target, pathspec: ['feature_file']);
repo.resetDefault(oid: repo.head.target, pathspec: ['feature_file']);
expect(repo.status['feature_file'], {GitStatus.wtModified});
head.free();
index.free();
});
test('throws when pathspec list is empty', () {
final head = repo.head;
expect(
() => repo.resetDefault(oid: head.target, pathspec: []),
() => repo.resetDefault(oid: repo.head.target, pathspec: []),
throwsA(isA<LibGit2Error>()),
);
head.free();
});
});
});