init static method
allowContent
if true
, doesn't check to see if the directory is empty
initialBranch
if provided, specifies the initial branch name.
If not provided, the default for git CLI is used.
Will fail if the source is a git directory (either at the root or a sub directory).
Implementation
static Future<GitDir> init(
String path, {
bool allowContent = false,
String? initialBranch,
}) async {
final source = Directory(path);
assert(source.existsSync());
if (allowContent == true) {
return _init(source, branchName: initialBranch);
}
// else, verify it's empty
final isEmpty = await source.list().isEmpty;
if (!isEmpty) {
throw ArgumentError('source Directory is not empty - $source');
}
return _init(source, branchName: initialBranch);
}