in builder/lib/src/commits_cache.dart [79:105]
Future<Commit?> _fetchByHash(String hash) async {
final commit = await firestore.getCommit(hash);
if (commit == null) return null;
final index = commit.index;
if (startIndex == null) {
_cacheCommit(commit);
} else if (index < startIndex!) {
for (var fetchIndex = startIndex! - 1; fetchIndex > index; --fetchIndex) {
// Other invocations may be fetching simultaneously.
if (fetchIndex < startIndex!) {
final infillCommit = await firestore.getCommitByIndex(fetchIndex);
_cacheCommit(infillCommit);
}
}
_cacheCommit(commit);
} else if (index > endIndex!) {
for (var fetchIndex = endIndex! + 1; fetchIndex < index; ++fetchIndex) {
// Other invocations may be fetching simultaneously.
if (fetchIndex > endIndex!) {
final infillCommit = await firestore.getCommitByIndex(fetchIndex);
_cacheCommit(infillCommit);
}
}
_cacheCommit(commit);
}
return commit;
}