refactor(repository)!: use Finalizer to automatically free allocated memory (#51)

BREAKING CHANGE: Return value of identity getter changed from Map<String, String> to Identity
This commit is contained in:
Aleksey Kulikov 2022-05-02 15:33:31 +03:00 committed by GitHub
parent aef440e345
commit 4e55d0f06c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 109 additions and 151 deletions

View file

@ -53,4 +53,4 @@ jobs:
run: flutter pub get
- name: Run tests
run: dart test --exclude-tags "remote_fetch" --platform=vm
run: dart test --reporter expanded --exclude-tags "remote_fetch" --platform=vm

View file

@ -78,16 +78,12 @@ You can instantiate a `Repository` class with a path to open an existing reposit
```dart
final repo = Repository.open('path/to/repository'); // => Repository
// Release memory allocated for Repository object when it's no longer needed
repo.free();
```
You can create new repository with provided path and optional `bare` argument if you want it to be bare:
```dart
final repo = Repository.init(path: 'path/to/folder', bare: true); // => Repository
// Release memory allocated for Repository object when it's no longer needed
repo.free();
```
You can clone the existing repository at provided url into local path:
@ -97,8 +93,6 @@ final repo = Repository.clone(
url: 'https://some.url/',
localPath: 'path/to/clone/into',
); // => Repository
// Release memory allocated for Repository object when it's no longer needed
repo.free();
```
Also you can discover the path to the '.git' directory of repository if you provide a path to subdirectory:
@ -135,9 +129,6 @@ ref.target.sha; // => '821ed6e80627b8769d170a293862f9fc60825226'
final oid = repo['821ed6e80627b8769d170a293862f9fc60825226']; // => Oid
final commit = Commit.lookup(repo: repo, oid: oid); // => Commit
commit.message; // => 'initial commit'
// Release memory allocated for Repository object when it's no longer needed
repo.free();
```
#### Writing to repository
@ -160,9 +151,6 @@ Commit.create(
tree: tree,
parents: [], // empty list for initial commit, 1 parent for regular and 2+ for merge commits
); // => Oid
// Release memory allocated for Repository object when it's no longer needed
repo.free();
```
---

View file

@ -6,6 +6,8 @@ import 'package:libgit2dart/src/bindings/credentials.dart'
as credentials_bindings;
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
import 'package:libgit2dart/src/bindings/remote.dart' as remote_bindings;
import 'package:libgit2dart/src/bindings/repository.dart'
as repository_bindings;
import 'package:libgit2dart/src/util.dart';
class RemoteCallbacks {
@ -112,17 +114,25 @@ class RemoteCallbacks {
int bare,
Pointer<Void> payload,
) {
final repoPointer = Repository.init(
var flagsInt = repositoryCbData!.flags.fold(
0,
(int acc, e) => acc | e.value,
);
if (repositoryCbData!.bare) {
flagsInt |= GitRepositoryInit.bare.value;
}
final repoPointer = repository_bindings.init(
path: repositoryCbData!.path,
bare: repositoryCbData!.bare,
flags: repositoryCbData!.flags,
flags: flagsInt,
mode: repositoryCbData!.mode,
workdirPath: repositoryCbData!.workdirPath,
description: repositoryCbData!.description,
templatePath: repositoryCbData!.templatePath,
initialHead: repositoryCbData!.initialHead,
originUrl: repositoryCbData!.originUrl,
).pointer;
);
repo[0] = repoPointer;

View file

@ -321,17 +321,19 @@ void setIdentity({
}
/// Retrieve the configured identity to use for reflogs.
Map<String, String> identity(Pointer<git_repository> repo) {
///
/// Returns list with name and email respectively.
List<String> identity(Pointer<git_repository> repo) {
final name = calloc<Pointer<Int8>>();
final email = calloc<Pointer<Int8>>();
libgit2.git_repository_ident(name, email, repo);
final identity = <String, String>{};
final identity = <String>[];
if (name.value == nullptr && email.value == nullptr) {
return identity;
} else {
identity[name.value.cast<Utf8>().toDartString()] =
email.value.cast<Utf8>().toDartString();
identity.add(name.value.cast<Utf8>().toDartString());
identity.add(email.value.cast<Utf8>().toDartString());
}
calloc.free(name);

View file

@ -272,9 +272,6 @@ class Reference {
/// Whether reference is a tag.
bool get isTag => bindings.isTag(_refPointer);
/// Repository where a reference resides.
Repository get owner => Repository(bindings.owner(_refPointer));
/// Compares two references.
bool equals(Reference other) {
return bindings.compare(

View file

@ -2,13 +2,14 @@ import 'dart:collection';
import 'dart:ffi';
import 'package:libgit2dart/libgit2dart.dart';
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
import 'package:libgit2dart/src/bindings/reference.dart' as reference_bindings;
import 'package:libgit2dart/src/bindings/reflog.dart' as bindings;
class RefLog with IterableMixin<RefLogEntry> {
/// Initializes a new instance of [RefLog] class from provided [Reference].
RefLog(Reference ref) {
_reflogPointer = bindings.read(
repoPointer: ref.owner.pointer,
repoPointer: reference_bindings.owner(ref.pointer),
name: ref.name,
);
_finalizer.attach(this, _reflogPointer, detach: this);
@ -19,7 +20,10 @@ class RefLog with IterableMixin<RefLogEntry> {
/// Deletes the reflog for the given reference.
static void delete(Reference ref) {
bindings.delete(repoPointer: ref.owner.pointer, name: ref.name);
bindings.delete(
repoPointer: reference_bindings.owner(ref.pointer),
name: ref.name,
);
}
/// Renames a reflog.

View file

@ -17,13 +17,14 @@ class Repository {
/// Initializes a new instance of the [Repository] class from provided
/// pointer to repository object in memory.
///
/// **IMPORTANT**: Should be freed to release allocated memory.
///
/// Note: For internal use. Instead, use one of:
/// - [Repository.init]
/// - [Repository.open]
/// - [Repository.clone]
Repository(this._repoPointer);
Repository(Pointer<git_repository> pointer) {
_repoPointer = pointer;
_finalizer.attach(this, _repoPointer, detach: this);
}
/// Creates new git repository at the provided [path].
///
@ -55,8 +56,6 @@ class Repository {
/// [originUrl] if set, then after the rest of the repository initialization
/// is completed, an "origin" remote will be added pointing to this URL.
///
/// **IMPORTANT**: Should be freed to release allocated memory.
///
/// Throws a [LibGit2Error] if error occured.
Repository.init({
required String path,
@ -87,6 +86,8 @@ class Repository {
initialHead: initialHead,
originUrl: originUrl,
);
_finalizer.attach(this, _repoPointer, detach: this);
}
/// Opens repository at provided [path].
@ -95,13 +96,13 @@ class Repository {
/// or to the working directory. For a bare repository, [path] should directly
/// point to the repository folder.
///
/// **IMPORTANT**: Should be freed to release allocated memory.
///
/// Throws a [LibGit2Error] if error occured.
Repository.open(String path) {
libgit2.git_libgit2_init();
_repoPointer = bindings.open(path);
_finalizer.attach(this, _repoPointer, detach: this);
}
/// Clones a remote repository at provided [url] into [localPath].
@ -128,8 +129,6 @@ class Repository {
/// [callbacks] is the combination of callback functions from [Callbacks]
/// object.
///
/// **IMPORTANT**: Should be freed to release allocated memory.
///
/// Throws a [LibGit2Error] if error occured.
Repository.clone({
required String url,
@ -151,6 +150,8 @@ class Repository {
checkoutBranch: checkoutBranch,
callbacks: callbacks,
);
_finalizer.attach(this, _repoPointer, detach: this);
}
late final Pointer<git_repository> _repoPointer;
@ -294,9 +295,12 @@ class Repository {
}
/// Configured identity to use for reflogs.
///
/// Returns map with name as key and email as value.
Map<String, String> get identity => bindings.identity(_repoPointer);
Identity get identity {
final identity = bindings.identity(_repoPointer);
return identity.isNotEmpty
? Identity(name: identity[0], email: identity[1])
: const Identity(name: '', email: '');
}
/// Whether repository was a shallow clone.
bool get isShallow => bindings.isShallow(_repoPointer);
@ -364,7 +368,10 @@ class Repository {
}
/// Releases memory allocated for repository object.
void free() => bindings.free(_repoPointer);
void free() {
bindings.free(_repoPointer);
_finalizer.detach(this);
}
@override
String toString() {
@ -736,6 +743,12 @@ class Repository {
}
}
// coverage:ignore-start
final _finalizer = Finalizer<Pointer<git_repository>>(
(pointer) => bindings.free(pointer),
);
// coverage:ignore-end
class RepositoryCallback {
/// Values used to override the repository creation and customization process
/// during a clone operation.
@ -807,3 +820,11 @@ class RepositoryCallback {
/// initialization is completed.
final String? originUrl;
}
class Identity {
/// Identity to use for reflogs.
const Identity({required this.name, required this.email});
final String name;
final String email;
}

View file

@ -119,9 +119,6 @@ class Submodule {
/// This will only work if the submodule is checked out into the working
/// directory.
///
/// **IMPORTANT**: Returned [Repository] object should be freed to release
/// allocated memory.
///
/// Throws a [LibGit2Error] if error occured.
Repository open() {
return Repository(bindings.open(_submodulePointer));

View file

@ -19,7 +19,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -52,7 +52,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -20,7 +20,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -21,7 +21,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -16,7 +16,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -34,7 +34,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -5,21 +5,6 @@ import 'package:path/path.dart' as p;
import 'package:test/test.dart';
void main() {
final cloneDir = Directory(
p.join(Directory.systemTemp.path, 'credentials_cloned'),
);
setUp(() {
if (cloneDir.existsSync()) {
cloneDir.deleteSync(recursive: true);
}
});
tearDown(() {
if (cloneDir.existsSync()) {
cloneDir.deleteSync(recursive: true);
}
});
group('Credentials', () {
test('initializes username/password credentials', () {
final credentials = const UserPass(
@ -78,6 +63,7 @@ void main() {
});
test('throws when provided username and password are incorrect', () {
final cloneDir = Directory.systemTemp.createTempSync('clone');
final callbacks = const Callbacks(
credentials: UserPass(
username: 'libgit2',
@ -93,11 +79,14 @@ void main() {
),
throwsA(isA<LibGit2Error>()),
);
cloneDir.deleteSync(recursive: true);
});
test(
'clones repository with provided keypair',
() {
final cloneDir = Directory.systemTemp.createTempSync('clone');
final keypair = Keypair(
username: 'git',
pubKey: p.join('test', 'assets', 'keys', 'id_rsa.pub'),
@ -114,12 +103,16 @@ void main() {
expect(repo.isEmpty, false);
repo.free();
if (Platform.isLinux || Platform.isMacOS) {
cloneDir.deleteSync(recursive: true);
}
},
testOn: '!linux',
);
test('throws when no credentials is provided', () {
final cloneDir = Directory.systemTemp.createTempSync('clone');
expect(
() => Repository.clone(
url: 'ssh://git@github.com/libgit2/TestGitRepository',
@ -127,9 +120,12 @@ void main() {
),
throwsA(isA<LibGit2Error>()),
);
cloneDir.deleteSync(recursive: true);
});
test('throws when provided keypair is invalid', () {
final cloneDir = Directory.systemTemp.createTempSync('clone');
final keypair = const Keypair(
username: 'git',
pubKey: 'invalid.pub',
@ -146,9 +142,12 @@ void main() {
),
throwsA(isA<LibGit2Error>()),
);
cloneDir.deleteSync(recursive: true);
});
test('throws when provided keypair is incorrect', () {
final cloneDir = Directory.systemTemp.createTempSync('clone');
final keypair = Keypair(
username: 'git',
pubKey: p.join('test', 'assets', 'keys', 'id_rsa.pub'),
@ -165,9 +164,12 @@ void main() {
),
throwsA(isA<LibGit2Error>()),
);
cloneDir.deleteSync(recursive: true);
});
test('throws when provided credential type is invalid', () {
final cloneDir = Directory.systemTemp.createTempSync('clone');
final callbacks = const Callbacks(
credentials: UserPass(
username: 'libgit2',
@ -183,11 +185,14 @@ void main() {
),
throwsA(isA<LibGit2Error>()),
);
cloneDir.deleteSync(recursive: true);
});
test(
'clones repository with provided keypair from memory',
() {
final cloneDir = Directory.systemTemp.createTempSync('clone');
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
.readAsStringSync();
final privateKey =
@ -208,12 +213,15 @@ void main() {
expect(repo.isEmpty, false);
repo.free();
if (Platform.isLinux || Platform.isMacOS) {
cloneDir.deleteSync(recursive: true);
}
},
testOn: '!linux',
);
test('throws when provided keypair from memory is incorrect', () {
final cloneDir = Directory.systemTemp.createTempSync('clone');
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
.readAsStringSync();
final keypair = KeypairFromMemory(
@ -232,9 +240,12 @@ void main() {
),
throwsA(isA<LibGit2Error>()),
);
cloneDir.deleteSync(recursive: true);
});
test('throws when provided keypair from agent is incorrect', () {
final cloneDir = Directory.systemTemp.createTempSync('clone');
final callbacks = const Callbacks(credentials: KeypairFromAgent('git'));
expect(
@ -245,6 +256,8 @@ void main() {
),
throwsA(isA<LibGit2Error>()),
);
cloneDir.deleteSync(recursive: true);
});
});
}

View file

@ -17,7 +17,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -127,7 +127,6 @@ index e69de29..c217c63 100644
});
tearDown(() {
repo.free();
if (Platform.isLinux || Platform.isMacOS) {
tmpDir.deleteSync(recursive: true);
}

View file

@ -20,7 +20,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});
@ -152,8 +151,6 @@ void main() {
p.join('test', 'assets', 'empty_bare.git'),
);
expect(() => bare.index.add('config'), throwsA(isA<LibGit2Error>()));
bare.free();
});
});
@ -203,8 +200,6 @@ void main() {
p.join('test', 'assets', 'empty_bare.git'),
);
expect(() => bare.index.addAll([]), throwsA(isA<LibGit2Error>()));
bare.free();
});
});
@ -229,8 +224,6 @@ void main() {
() => bare.index.updateAll(['not_there']),
throwsA(isA<LibGit2Error>()),
);
bare.free();
});
});
@ -316,7 +309,6 @@ void main() {
expect(() => repo.index.writeTree(), throwsA(isA<LibGit2Error>()));
repo.free();
tmpDir.deleteSync(recursive: true);
});
@ -356,7 +348,6 @@ void main() {
expect(conflictedFile.their?.path, 'feature_file');
expect(conflictedFile.toString(), contains('ConflictEntry{'));
conflictRepo.free();
repoDir.deleteSync(recursive: true);
});
@ -381,7 +372,6 @@ void main() {
expect(conflictedFile.their?.path, 'conflict_file');
expect(conflictedFile.toString(), contains('ConflictEntry{'));
conflictRepo.free();
repoDir.deleteSync(recursive: true);
});
@ -407,7 +397,6 @@ void main() {
expect(conflictedFile.their?.path, 'feature_file');
expect(conflictedFile.toString(), contains('ConflictEntry{'));
conflictRepo.free();
repoDir.deleteSync(recursive: true);
});
@ -432,7 +421,6 @@ void main() {
expect(conflictedFile.their?.path, null);
expect(conflictedFile.toString(), contains('ConflictEntry{'));
conflictRepo.free();
repoDir.deleteSync(recursive: true);
});
@ -465,7 +453,6 @@ void main() {
expect(index.conflicts, isEmpty);
expect(index.conflicts['conflict_file'], null);
conflictRepo.free();
repoDir.deleteSync(recursive: true);
});
@ -502,7 +489,6 @@ void main() {
expect(index.hasConflicts, false);
expect(index.conflicts, isEmpty);
conflictRepo.free();
repoDir.deleteSync(recursive: true);
});

View file

@ -136,7 +136,6 @@ Santa Claus <santa.claus@northpole.xx> <me@company.xx>
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -19,7 +19,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -29,7 +29,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -20,7 +20,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -20,7 +20,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -19,7 +19,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -50,7 +50,6 @@ index e69de29..0000000
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -21,7 +21,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -19,7 +19,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -19,7 +19,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -30,8 +30,6 @@ void main() {
});
tearDown(() {
originRepo.free();
clonedRepo.free();
tmpDir.deleteSync(recursive: true);
if (cloneDir.existsSync()) {
cloneDir.deleteSync(recursive: true);

View file

@ -18,7 +18,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});
@ -474,13 +473,8 @@ Total 69 (delta 0), reused 1 (delta 0), pack-reused 68
);
test('pushes with update reference callback', () {
final originDir =
Directory(p.join(Directory.systemTemp.path, 'origin_testrepo'));
final originDir = Directory.systemTemp.createTempSync('origin');
if (originDir.existsSync()) {
originDir.deleteSync(recursive: true);
}
originDir.createSync();
copyRepo(
from: Directory(p.join('test', 'assets', 'empty_bare.git')),
to: originDir,
@ -505,8 +499,9 @@ Total 69 (delta 0), reused 1 (delta 0), pack-reused 68
);
expect(updateRefOutput, {'refs/heads/master': ''});
originRepo.free();
originDir.delete(recursive: true);
if (Platform.isLinux || Platform.isMacOS) {
originDir.deleteSync(recursive: true);
}
});
test('throws when trying to push to invalid url', () {

View file

@ -37,8 +37,6 @@ void main() {
expect(clonedRepo.isEmpty, false);
expect(clonedRepo.isBare, false);
clonedRepo.free();
});
test('clones repository as bare', () {
@ -50,8 +48,6 @@ void main() {
expect(clonedRepo.isEmpty, false);
expect(clonedRepo.isBare, true);
clonedRepo.free();
});
test('clones repository with provided checkout branch name', () {
@ -65,8 +61,6 @@ void main() {
expect(clonedRepo.isEmpty, false);
expect(clonedRepo.isBare, true);
expect(clonedRepo.head.name, 'refs/heads/feature');
clonedRepo.free();
});
test(
@ -82,8 +76,6 @@ void main() {
expect(clonedRepo.isBare, false);
expect(clonedRepo.remotes, ['test']);
expect(clonedRepo.references, contains('refs/remotes/test/master'));
clonedRepo.free();
});
test('clones repository with provided remote callback ', () {
@ -105,8 +97,6 @@ void main() {
expect(clonedRepo.remotes, ['test']);
expect(clonedRepo.references, contains('refs/remotes/spec/master'));
expect(remote.fetchRefspecs, [fetchRefspec]);
clonedRepo.free();
});
test('throws when cloning repository with invalid remote callback', () {
@ -132,14 +122,16 @@ void main() {
final clonedRepo = Repository.clone(
url: tmpDir.path,
localPath: cloneDir.path,
repositoryCallback: RepositoryCallback(path: callbackPath.path),
repositoryCallback: RepositoryCallback(
path: callbackPath.path,
bare: true,
),
);
expect(clonedRepo.isEmpty, false);
expect(clonedRepo.isBare, false);
expect(clonedRepo.path, contains('/callbackRepo/.git/'));
expect(clonedRepo.isBare, true);
expect(clonedRepo.path, contains('/callbackRepo/'));
clonedRepo.free();
callbackPath.deleteSync(recursive: true);
});

View file

@ -20,10 +20,6 @@ void main() {
repo = Repository.open(p.join('test', 'assets', 'empty_bare.git'));
});
tearDown(() {
repo.free();
});
test('opens successfully', () {
expect(repo, isA<Repository>());
});
@ -52,10 +48,6 @@ void main() {
);
});
tearDown(() {
repo.free();
});
test('opens standart repository from working directory successfully', () {
expect(repo, isA<Repository>());
});
@ -89,12 +81,18 @@ void main() {
test('sets identity ', () {
repo.setIdentity(name: 'name', email: 'email@email.com');
expect(repo.identity, {'name': 'email@email.com'});
final identity = repo.identity;
expect(identity.name, 'name');
expect(identity.email, 'email@email.com');
});
test('unsets identity', () {
repo.setIdentity(name: null, email: null);
expect(repo.identity, isEmpty);
final identity = repo.identity;
expect(identity.name, '');
expect(identity.email, '');
});
test('checks if shallow clone', () {

View file

@ -24,8 +24,6 @@ void main() {
expect(repo.path, contains('init_repo'));
expect(repo.isBare, true);
repo.free();
});
test('creates new standard repo at provided path', () {
@ -34,8 +32,6 @@ void main() {
expect(repo.path, contains('init_repo/.git/'));
expect(repo.isBare, false);
expect(repo.isEmpty, true);
repo.free();
});
test('creates new standard repo with provided options', () {
@ -54,8 +50,6 @@ void main() {
'test repo',
);
expect(Remote.lookup(repo: repo, name: 'origin').url, 'test.url');
repo.free();
});
});
}

View file

@ -19,7 +19,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});
@ -165,8 +164,6 @@ void main() {
final bare = Repository.open(p.join('test', 'assets', 'empty_bare.git'));
expect(() => bare.status, throwsA(isA<LibGit2Error>()));
bare.free();
});
test('cleans up state', () {

View file

@ -19,7 +19,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -18,7 +18,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -24,7 +24,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -24,7 +24,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -20,7 +20,6 @@ void main() {
});
tearDown(() {
repo.free();
try {
tmpDir.deleteSync(recursive: true);
} catch (e) {
@ -99,8 +98,6 @@ void main() {
submodule.workdirOid?.sha,
'49322bb17d3acc9146f98c97d078513228bbf3c0',
);
submoduleRepo.free();
});
test('throws when trying to open repository for not initialized submodule',
@ -120,8 +117,6 @@ void main() {
expect(submodule.path, 'test');
expect(submodule.url, submoduleUrl);
expect(submoduleRepo.isEmpty, false);
submoduleRepo.free();
});
test('throws when trying to add submodule with wrong url', () {
@ -197,9 +192,6 @@ void main() {
updatedSubmRepoConfig['remote.origin.url'].value,
'https://updated.com/',
);
submRepo.free();
updatedSubmRepo.free();
});
test('reloads info', () {

View file

@ -21,7 +21,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -19,7 +19,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -19,7 +19,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
});

View file

@ -22,7 +22,6 @@ void main() {
});
tearDown(() {
repo.free();
tmpDir.deleteSync(recursive: true);
if (worktreeDir.existsSync()) {
worktreeDir.deleteSync(recursive: true);