initTestDir function
Initializes a test directory
Implementation
Future<Directory> initTestDir() async {
// Never use '/tmp' on Windows: Dart resolves it against the current
// drive (e.g. P:\tmp), while git resolves the same string against its
// own MSYS root - the two halves of a test repo end up on different
// paths and every push fails.
final tmpBase = !Platform.isWindows && await Directory('/tmp').exists()
? Directory('/tmp')
: Directory.systemTemp;
final tmp = await tmpBase.createTemp('gg_git_test');
final testDir = Directory('${tmp.path}/test');
if (await testDir.exists()) {
await testDir.delete(recursive: true);
}
await testDir.create(recursive: true);
return testDir;
}