list method

  1. @override
Future<Map<String, GitObjectId>> list([
  1. String prefix = 'refs/'
])
override

Every ref whose name starts with prefix.

Implementation

@override
Future<Map<String, GitObjectId>> list([String prefix = 'refs/']) async {
  final out = <String, GitObjectId>{
    for (final e in _packed().entries)
      if (e.key.startsWith(prefix)) e.key: e.value,
  };
  final refsDir = Directory(p.join(gitDir, 'refs'));
  if (refsDir.existsSync()) {
    for (final f in refsDir.listSync(recursive: true).whereType<File>()) {
      if (f.path.endsWith('.lock')) continue;
      final name = p.posix.joinAll(p.split(p.relative(f.path, from: gitDir)));
      if (!name.startsWith(prefix)) continue;
      final id = await read(name);
      if (id != null) out[name] = id;
    }
  }
  return out;
}