feat(repository)!: add more aliases for api methods

BREAKING CHANGE: Make repository entry point for most operations
This commit is contained in:
Aleksey Kulikov 2021-10-11 20:06:36 +03:00
parent 9205a3ad82
commit 3a0fa75929
51 changed files with 1380 additions and 1062 deletions

View file

@ -3,29 +3,31 @@ import 'package:path/path.dart' as p;
final tmpDir = Directory.systemTemp.createTempSync('testrepo');
Future<Directory> setupRepo(Directory repoDir) async {
if (await tmpDir.exists()) {
await tmpDir.delete(recursive: true);
Directory setupRepo(Directory repoDir) {
if (tmpDir.existsSync()) {
tmpDir.deleteSync(recursive: true);
}
await copyRepo(from: repoDir, to: await tmpDir.create());
tmpDir.createSync();
copyRepo(from: repoDir, to: tmpDir);
return tmpDir;
}
Future<void> copyRepo({required Directory from, required Directory to}) async {
await for (final entity in from.list()) {
void copyRepo({required Directory from, required Directory to}) {
for (final entity in from.listSync()) {
if (entity is Directory) {
Directory newDir;
if (p.basename(entity.path) == '.gitdir') {
newDir = Directory(p.join(to.absolute.path, '.git'));
newDir = Directory(p.join(to.absolute.path, '.git'))..createSync();
} else {
newDir = Directory(p.join(to.absolute.path, p.basename(entity.path)));
newDir = Directory(p.join(to.absolute.path, p.basename(entity.path)))
..createSync();
}
await copyRepo(from: entity.absolute, to: await newDir.create());
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'));
entity.copySync(p.join(to.path, '.gitignore'));
} else {
await entity.copy(p.join(to.path, p.basename(entity.path)));
entity.copySync(p.join(to.path, p.basename(entity.path)));
}
}
}