mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat(merge): add bindings and api for merge analysis
This commit is contained in:
parent
1f2d00b177
commit
223cc7cc14
5 changed files with 231 additions and 13 deletions
|
@ -21,3 +21,36 @@ Pointer<git_oid> mergeBase(
|
|||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
/// Analyzes the given branch(es) and determines the opportunities for merging them
|
||||
/// into a reference.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
List<int> analysis(
|
||||
Pointer<git_repository> repo,
|
||||
Pointer<git_reference> ourRef,
|
||||
Pointer<Pointer<git_annotated_commit>> theirHead,
|
||||
int theirHeadsLen,
|
||||
) {
|
||||
final analysisOut = calloc<Int32>();
|
||||
final preferenceOut = calloc<Int32>();
|
||||
final error = libgit2.git_merge_analysis_for_ref(
|
||||
analysisOut,
|
||||
preferenceOut,
|
||||
repo,
|
||||
ourRef,
|
||||
theirHead,
|
||||
theirHeadsLen,
|
||||
);
|
||||
var result = <int>[];
|
||||
|
||||
if (error < 0) {
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
} else {
|
||||
result.add(analysisOut.value);
|
||||
result.add(preferenceOut.value);
|
||||
calloc.free(analysisOut);
|
||||
calloc.free(preferenceOut);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue