mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
test(repository): test against repo copied into tmp directory
This commit is contained in:
parent
9acf3a8a9e
commit
be680595bc
50 changed files with 1021 additions and 107 deletions
27
test/helpers/util.dart
Normal file
27
test/helpers/util.dart
Normal file
|
@ -0,0 +1,27 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
Future<void> copyRepo({
|
||||
required Directory from,
|
||||
required Directory to,
|
||||
}) async {
|
||||
await for (final entity in from.list()) {
|
||||
if (entity is Directory) {
|
||||
late Directory newDir;
|
||||
if (p.basename(entity.path) == '.gitdir') {
|
||||
newDir = Directory(p.join(to.absolute.path, '.git'));
|
||||
} else {
|
||||
newDir = Directory(p.join(to.absolute.path, p.basename(entity.path)));
|
||||
}
|
||||
await newDir.create();
|
||||
await copyRepo(from: entity.absolute, to: newDir);
|
||||
} else if (entity is File) {
|
||||
if (p.basename(entity.path) == 'gitignore') {
|
||||
await entity.copy(p.join(to.path, '.gitignore'));
|
||||
} else {
|
||||
await entity.copy(p.join(to.path, p.basename(entity.path)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue