load static method

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

Implementation

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

  if (!(await isValidRepo(gitRootDir, fs: fs))) {
    throw InvalidRepoException(gitRootDir);
  }

  var repo = GitRepository._internal(rootDir: gitRootDir, fs: fs);

  var configPath = p.join(repo.gitDir, 'config');
  var configFileContents = await fs.file(configPath).readAsString();
  repo.config = Config(configFileContents);

  repo.objStorage = ObjectStorageExceptionCatcher(
    storage: ObjectStorage(repo.gitDir, fs),
  );
  repo.refStorage = ReferenceStorage(repo.gitDir, fs);
  repo.indexStorage = IndexStorage(repo.gitDir, fs);

  return repo;
}