addDirectoryToIndex method

Future<void> addDirectoryToIndex(
  1. GitIndex index,
  2. String dirPath, {
  3. bool recursive = false,
})

Implementation

Future<void> addDirectoryToIndex(GitIndex index, String dirPath,
    {bool recursive = false}) async {
  dirPath = normalizePath(dirPath);

  var dir = fs.directory(dirPath);
  await for (var fsEntity
      in dir.list(recursive: recursive, followLinks: false)) {
    if (fsEntity.path.startsWith(gitDir)) {
      continue;
    }
    var stat = await fsEntity.stat();
    if (stat.type != FileSystemEntityType.file) {
      continue;
    }

    await addFileToIndex(index, fsEntity.path);
  }
}