initLocalGit function
Init local git repository in directory
Implementation
Future<void> initLocalGit(Directory testDir) async {
_setupGitHub(testDir);
final localDir = testDir;
// A repository git creates here is on »main« right away. Only one that
// was there before may sit on another branch.
final isNew =
FileSystemEntity.typeSync(join(localDir.path, '.git')) ==
FileSystemEntityType.notFound;
final result = await ggRunProcess('git', [
'init',
'--initial-branch=main',
], workingDirectory: localDir.path);
_throw('Could not initialize local git repository', result);
if (isNew) {
return;
}
final result2 = await ggRunProcess('git', [
'checkout',
'-b',
'main',
], workingDirectory: localDir.path);
_throw('Could not create main branch', result2);
}