listReferences method
Implementation
Future<List<Reference>> listReferences(String prefix) async {
assert(prefix.startsWith(refPrefix));
var refs = <Reference>[];
var refLocation = p.join(dotGitDir, prefix);
var processedRefNames = <ReferenceName>{};
var dir = fs.directory(refLocation);
if (!dir.existsSync()) {
return refs;
}
var stream = dir.list(recursive: true);
await for (var fsEntity in stream) {
if (fsEntity.statSync().type != FileSystemEntityType.file) {
continue;
}
if (fsEntity.basename.startsWith('.')) {
continue;
}
var refName =
ReferenceName(fsEntity.path.substring(dotGitDir.length + 1));
var ref = await reference(refName);
if (ref != null) {
refs.add(ref);
processedRefNames.add(refName);
}
}
for (var ref in await _packedRefs()) {
if (processedRefNames.contains(ref.name)) {
continue;
}
if (ref.name.value.startsWith(prefix)) {
refs.add(ref);
}
}
return refs;
}