commitPreOrderIterator function

Stream<GitCommit> commitPreOrderIterator({
  1. required ObjectStorage objStorage,
  2. required GitCommit from,
})

Implementation

Stream<GitCommit> commitPreOrderIterator({
  required ObjectStorage objStorage,
  required GitCommit from,
}) async* {
  var stack = List<GitHash>.from([from.hash]);
  var seen = <GitHash>{};

  while (stack.isNotEmpty) {
    var hash = stack.removeLast();
    if (seen.contains(hash)) {
      continue;
    }
    seen.add(hash);

    var result = await objStorage.readCommit(hash);
    var commit = result.get();

    stack.addAll(commit.parents.reversed);
    yield commit;
  }
}