revList method

Future<List<Commit>> revList(
  1. String revision, {
  2. bool firstParentOnly = false,
})

Implementation

Future<List<Commit>> revList(String revision, {bool firstParentOnly = false}) async {
  // use commit date not author date. commit date is  the one between the prev and next commit. Author date could be anything
  final String? result = await _git(
    'rev-list --pretty=%ct%n${firstParentOnly ? ' --first-parent' : ''} $revision',
    emptyResultIsError: false,
  );
  if (result == null) return [];

  return result.split('\n\n').where((c) => c.isNotEmpty).map((rawCommit) {
    final lines = rawCommit.split('\n');
    return Commit(lines[0].replaceFirst('commit ', ''), lines[1]);
  }).toList(growable: false);
}