feat(reference): add ability to get log of reference

This commit is contained in:
Aleksey Kulikov 2021-08-06 12:31:07 +03:00
parent a97dcaa0d3
commit 58fa54f24a
5 changed files with 30 additions and 7 deletions

View file

@ -2,6 +2,7 @@ import 'dart:ffi';
import 'bindings/libgit2_bindings.dart';
import 'bindings/reference.dart' as bindings;
import 'oid.dart';
import 'reflog.dart';
import 'util.dart';
enum ReferenceType { direct, symbolic }
@ -145,6 +146,18 @@ class Reference {
return bindings.hasLog(repo, name);
}
/// Returns a list with entries of reference log.
List<RefLogEntry> get log {
final reflog = RefLog(this);
var log = <RefLogEntry>[];
for (var i = 0; i < reflog.count; i++) {
log.add(reflog.entryAt(i));
}
return log;
}
/// Checks if a reference is a local branch.
bool get isBranch => bindings.isBranch(_refPointer);