feat(revwalk): add bindings and api

This commit is contained in:
Aleksey Kulikov 2021-08-31 17:19:21 +03:00
parent e0e3742457
commit 2e0486c641
7 changed files with 424 additions and 0 deletions

View file

@ -1,4 +1,7 @@
import 'dart:ffi';
import 'package:libgit2dart/src/enums.dart';
import 'package:libgit2dart/src/revwalk.dart';
import 'commit.dart';
import 'config.dart';
import 'index.dart';
@ -320,4 +323,19 @@ class Repository {
}
return Commit.lookup(this, oid);
}
/// Returns the list of commits starting from provided [oid].
///
/// If [sorting] isn't provided default will be used (reverse chronological order, like in git).
List<Commit> log(Oid oid, [GitSort sorting = GitSort.none]) {
final walker = RevWalk(this);
if (sorting != GitSort.none) {
walker.sorting(sorting);
}
walker.push(oid);
final result = walker.walk();
walker.free();
return result;
}
}