feat(reference): add more bindings and API methods (#28)

This commit is contained in:
Aleksey Kulikov 2021-12-22 19:53:38 +03:00 committed by GitHub
parent fb4694cf06
commit ff2dd8b408
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 0 deletions

View file

@ -139,6 +139,11 @@ class Reference {
refdb_bindings.free(refdb);
}
/// Creates a copy of an existing reference.
///
/// **IMPORTANT**: Should be freed to release allocated memory.
Reference duplicate() => Reference(bindings.duplicate(_refPointer));
/// Type of the reference.
ReferenceType get type {
return bindings.referenceType(_refPointer) == 1
@ -242,6 +247,17 @@ class Reference {
);
}
/// Ensures there is a reflog for a particular reference.
///
/// Makes sure that successive updates to the reference will append to its
/// log.
///
/// Throws a [LibGit2Error] if error occured.
void ensureLog() {
final owner = bindings.owner(_refPointer);
bindings.ensureLog(repoPointer: owner, refName: name);
}
/// [RefLog] object.
///
/// **IMPORTANT**: Should be freed to release allocated memory.