test: improve coverage (#44)

This commit is contained in:
Aleksey Kulikov 2022-01-26 16:11:38 +03:00 committed by GitHub
parent bad5e20581
commit 7b57c41253
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 171 additions and 40 deletions

View file

@ -347,18 +347,10 @@ Pointer<git_oid> treeOid(Pointer<git_commit> commit) {
}
/// Get the tree pointed to by a commit.
///
/// Throws a [LibGit2Error] if error occured.
Pointer<git_tree> tree(Pointer<git_commit> commit) {
final out = calloc<Pointer<git_tree>>();
final error = libgit2.git_commit_tree(out, commit);
if (error < 0) {
calloc.free(out);
throw LibGit2Error(libgit2.git_error_last());
} else {
return out.value;
}
libgit2.git_commit_tree(out, commit);
return out.value;
}
/// Reverts the given commit, producing changes in the index and working

View file

@ -525,9 +525,5 @@ void conflictCleanup(Pointer<git_index> index) {
}
}
/// Get the repository this index relates to.
Pointer<git_repository> owner(Pointer<git_index> index) =>
libgit2.git_index_owner(index);
/// Free an existing index object.
void free(Pointer<git_index> index) => libgit2.git_index_free(index);

View file

@ -26,10 +26,6 @@ Pointer<git_tree> lookup({
}
}
/// Get the repository that contains the tree.
Pointer<git_repository> owner(Pointer<git_tree> tree) =>
libgit2.git_tree_owner(tree);
/// Lookup a tree entry by its position in the tree.
///
/// This returns a tree entry that is owned by the tree. You don't have to free

View file

@ -3,7 +3,7 @@ import 'package:libgit2dart/src/bindings/checkout.dart' as bindings;
import 'package:libgit2dart/src/bindings/object.dart' as object_bindings;
class Checkout {
const Checkout._();
const Checkout._(); // coverage:ignore-line
/// Updates files in the index and the working tree to match the content of
/// the commit pointed at by HEAD.

View file

@ -314,11 +314,11 @@ class Commit {
///
/// Note that a commit is not considered a descendant of itself, in contrast
/// to `git merge-base --is-ancestor`.
bool descendantOf(Commit ancestor) {
bool descendantOf(Oid ancestor) {
return graph_bindings.descendantOf(
repoPointer: bindings.owner(_commitPointer),
commitPointer: bindings.id(_commitPointer),
ancestorPointer: bindings.id(ancestor.pointer),
ancestorPointer: ancestor.pointer,
);
}

View file

@ -5,7 +5,7 @@ import 'package:libgit2dart/libgit2dart.dart';
import 'package:libgit2dart/src/util.dart';
class Libgit2 {
Libgit2._();
Libgit2._(); // coverage:ignore-line
/// Returns libgit2 version number.
static String get version {

View file

@ -5,7 +5,7 @@ import 'package:libgit2dart/src/bindings/merge.dart' as bindings;
import 'package:libgit2dart/src/util.dart';
class Merge {
const Merge._();
const Merge._(); // coverage:ignore-line
/// Finds a merge base between [commits].
///