mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 20:59:08 -04:00
test: improve coverage
This commit is contained in:
parent
d75acbfdd3
commit
d6eae1e9ed
71 changed files with 710 additions and 229 deletions
|
@ -21,7 +21,16 @@ Pointer<git_diff> indexToWorkdir({
|
|||
interhunkLines: interhunkLines,
|
||||
);
|
||||
|
||||
libgit2.git_diff_index_to_workdir(out, repoPointer, indexPointer, opts);
|
||||
final error = libgit2.git_diff_index_to_workdir(
|
||||
out,
|
||||
repoPointer,
|
||||
indexPointer,
|
||||
opts,
|
||||
);
|
||||
|
||||
if (error < 0) {
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
}
|
||||
|
||||
calloc.free(opts);
|
||||
|
||||
|
@ -46,7 +55,7 @@ Pointer<git_diff> treeToIndex({
|
|||
interhunkLines: interhunkLines,
|
||||
);
|
||||
|
||||
libgit2.git_diff_tree_to_index(
|
||||
final error = libgit2.git_diff_tree_to_index(
|
||||
out,
|
||||
repoPointer,
|
||||
treePointer,
|
||||
|
@ -54,6 +63,10 @@ Pointer<git_diff> treeToIndex({
|
|||
opts,
|
||||
);
|
||||
|
||||
if (error < 0) {
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
}
|
||||
|
||||
calloc.free(opts);
|
||||
|
||||
return out.value;
|
||||
|
@ -76,7 +89,16 @@ Pointer<git_diff> treeToWorkdir({
|
|||
interhunkLines: interhunkLines,
|
||||
);
|
||||
|
||||
libgit2.git_diff_tree_to_workdir(out, repoPointer, treePointer, opts);
|
||||
final error = libgit2.git_diff_tree_to_workdir(
|
||||
out,
|
||||
repoPointer,
|
||||
treePointer,
|
||||
opts,
|
||||
);
|
||||
|
||||
if (error < 0) {
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
}
|
||||
|
||||
calloc.free(opts);
|
||||
|
||||
|
@ -101,7 +123,7 @@ Pointer<git_diff> treeToTree({
|
|||
interhunkLines: interhunkLines,
|
||||
);
|
||||
|
||||
libgit2.git_diff_tree_to_tree(
|
||||
final error = libgit2.git_diff_tree_to_tree(
|
||||
out,
|
||||
repoPointer,
|
||||
oldTreePointer,
|
||||
|
@ -109,6 +131,10 @@ Pointer<git_diff> treeToTree({
|
|||
opts,
|
||||
);
|
||||
|
||||
if (error < 0) {
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
}
|
||||
|
||||
calloc.free(opts);
|
||||
|
||||
return out.value;
|
||||
|
@ -351,15 +377,18 @@ Pointer<git_diff_options> _diffOptionsInit({
|
|||
required int interhunkLines,
|
||||
}) {
|
||||
final opts = calloc<git_diff_options>();
|
||||
final optsError =
|
||||
libgit2.git_diff_options_init(opts, GIT_DIFF_OPTIONS_VERSION);
|
||||
opts.ref.flags = flags;
|
||||
opts.ref.context_lines = contextLines;
|
||||
opts.ref.interhunk_lines = interhunkLines;
|
||||
final optsError = libgit2.git_diff_options_init(
|
||||
opts,
|
||||
GIT_DIFF_OPTIONS_VERSION,
|
||||
);
|
||||
|
||||
if (optsError < 0) {
|
||||
calloc.free(opts);
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
} else {
|
||||
opts.ref.flags = flags;
|
||||
opts.ref.context_lines = contextLines;
|
||||
opts.ref.interhunk_lines = interhunkLines;
|
||||
return opts;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,16 +120,16 @@ void merge({
|
|||
String mergeFileFromIndex({
|
||||
required Pointer<git_repository> repoPointer,
|
||||
required Pointer<git_index_entry>? ancestorPointer,
|
||||
required Pointer<git_index_entry>? oursPointer,
|
||||
required Pointer<git_index_entry>? theirsPointer,
|
||||
required Pointer<git_index_entry> oursPointer,
|
||||
required Pointer<git_index_entry> theirsPointer,
|
||||
}) {
|
||||
final out = calloc<git_merge_file_result>();
|
||||
final error = libgit2.git_merge_file_from_index(
|
||||
out,
|
||||
repoPointer,
|
||||
ancestorPointer ?? nullptr,
|
||||
oursPointer ?? nullptr,
|
||||
theirsPointer ?? nullptr,
|
||||
oursPointer,
|
||||
theirsPointer,
|
||||
nullptr,
|
||||
);
|
||||
|
||||
|
|
|
@ -235,6 +235,8 @@ bool isTag(Pointer<git_reference> ref) {
|
|||
///
|
||||
/// The message for the reflog will be ignored if the reference does not belong in the
|
||||
/// standard set (HEAD, branches and remote-tracking branches) and it does not have a reflog.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Pointer<git_reference> createDirect({
|
||||
required Pointer<git_repository> repoPointer,
|
||||
required String name,
|
||||
|
@ -288,6 +290,8 @@ Pointer<git_reference> createDirect({
|
|||
///
|
||||
/// The message for the reflog will be ignored if the reference does not belong in the standard
|
||||
/// set (HEAD, branches and remote-tracking branches) and it does not have a reflog.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Pointer<git_reference> createSymbolic({
|
||||
required Pointer<git_repository> repoPointer,
|
||||
required String name,
|
||||
|
|
|
@ -73,7 +73,7 @@ Pointer<git_tree_entry> getByName({
|
|||
/// Retrieve a tree entry contained in a tree or in any of its subtrees, given its relative path.
|
||||
///
|
||||
/// Unlike the other lookup functions, the returned tree entry is owned by the user and must be
|
||||
/// freed explicitly with `entryFree()`.
|
||||
/// freed explicitly with [entryFree].
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Pointer<git_tree_entry> getByPath({
|
||||
|
@ -122,7 +122,7 @@ int compare({
|
|||
/// Free a user-owned tree entry.
|
||||
///
|
||||
/// IMPORTANT: This function is only needed for tree entries owned by the user,
|
||||
/// such as `getByPath()`.
|
||||
/// such as [getByPath].
|
||||
void entryFree(Pointer<git_tree_entry> entry) =>
|
||||
libgit2.git_tree_entry_free(entry);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue