isValidRepo static method

Future<bool> isValidRepo(
  1. String gitRootDir, {
  2. FileSystem? fs,
})

Implementation

static Future<bool> isValidRepo(String gitRootDir, {FileSystem? fs}) async {
  fs ??= const LocalFileSystemWithChecks();

  var isDir = await fs.isDirectory(gitRootDir);
  if (!isDir) {
    return false;
  }

  var repo = GitRepository._internal(rootDir: gitRootDir, fs: fs);
  var dotGitExists = await fs.isDirectory(repo.gitDir);
  if (!dotGitExists) {
    return false;
  }

  var configPath = p.join(repo.gitDir, 'config');
  if (!fs.isFileSync(configPath)) {
    return false;
  }

  return true;
}