mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
feat(repository): add ability to clone repository
This commit is contained in:
parent
3c1a6b4ab4
commit
5680fd8674
3 changed files with 136 additions and 1 deletions
68
test/repository_clone_test.dart
Normal file
68
test/repository_clone_test.dart
Normal file
|
@ -0,0 +1,68 @@
|
|||
import 'dart:io';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'helpers/util.dart';
|
||||
|
||||
void main() {
|
||||
late Repository repo;
|
||||
late Directory tmpDir;
|
||||
final cloneDir = Directory('${Directory.systemTemp.path}/cloned');
|
||||
|
||||
setUp(() async {
|
||||
tmpDir = await setupRepo(Directory('test/assets/testrepo/'));
|
||||
repo = Repository.open(tmpDir.path);
|
||||
|
||||
if (await cloneDir.exists()) {
|
||||
cloneDir.delete(recursive: true);
|
||||
}
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
repo.free();
|
||||
await tmpDir.delete(recursive: true);
|
||||
cloneDir.delete(recursive: true);
|
||||
});
|
||||
|
||||
group('Repository.clone', () {
|
||||
test('successfully clones repository', () async {
|
||||
final clonedRepo = Repository.clone(
|
||||
url: tmpDir.path,
|
||||
localPath: cloneDir.path,
|
||||
);
|
||||
|
||||
expect(clonedRepo.isEmpty, false);
|
||||
expect(clonedRepo.isBare, false);
|
||||
|
||||
clonedRepo.free();
|
||||
});
|
||||
|
||||
test('successfully clones repository as bare', () async {
|
||||
final clonedRepo = Repository.clone(
|
||||
url: tmpDir.path,
|
||||
localPath: cloneDir.path,
|
||||
bare: true,
|
||||
);
|
||||
|
||||
expect(clonedRepo.isEmpty, false);
|
||||
expect(clonedRepo.isBare, true);
|
||||
|
||||
clonedRepo.free();
|
||||
});
|
||||
|
||||
test('successfully clones repository with provided checkout branch name',
|
||||
() async {
|
||||
final clonedRepo = Repository.clone(
|
||||
url: tmpDir.path,
|
||||
localPath: cloneDir.path,
|
||||
bare: true,
|
||||
checkoutBranch: 'feature',
|
||||
);
|
||||
|
||||
expect(clonedRepo.isEmpty, false);
|
||||
expect(clonedRepo.isBare, true);
|
||||
expect(clonedRepo.head.name, 'refs/heads/feature');
|
||||
|
||||
clonedRepo.free();
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue