mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat(diff): add more bindings and api methods (#18)
This commit is contained in:
parent
6c1735d67d
commit
b3e9f6dd1a
3 changed files with 238 additions and 29 deletions
|
@ -1362,27 +1362,56 @@ class Repository {
|
|||
/// [location] (directly in the working directory (default), the index or
|
||||
/// both).
|
||||
///
|
||||
/// [hunkIndex] is optional index of the hunk to apply.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
void apply({
|
||||
required Diff diff,
|
||||
int? hunkIndex,
|
||||
GitApplyLocation location = GitApplyLocation.workdir,
|
||||
}) {
|
||||
diff_bindings.apply(
|
||||
repoPointer: _repoPointer,
|
||||
diffPointer: diff.pointer,
|
||||
hunkIndex: hunkIndex,
|
||||
location: location.value,
|
||||
);
|
||||
}
|
||||
|
||||
/// Applies the [diff] to the [tree], and returns the resulting image as an
|
||||
/// index.
|
||||
///
|
||||
/// [hunkIndex] is optional index of the hunk to apply.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Index applyToTree({
|
||||
required Diff diff,
|
||||
required Tree tree,
|
||||
int? hunkIndex,
|
||||
}) {
|
||||
return Index(
|
||||
diff_bindings.applyToTree(
|
||||
repoPointer: _repoPointer,
|
||||
diffPointer: diff.pointer,
|
||||
treePointer: tree.pointer,
|
||||
hunkIndex: hunkIndex,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Checks if the [diff] will apply to provided [location] (the working
|
||||
/// directory (default), the index or both).
|
||||
///
|
||||
/// [hunkIndex] is optional index of the hunk to apply.
|
||||
bool applies({
|
||||
required Diff diff,
|
||||
int? hunkIndex,
|
||||
GitApplyLocation location = GitApplyLocation.workdir,
|
||||
}) {
|
||||
return diff_bindings.apply(
|
||||
repoPointer: _repoPointer,
|
||||
diffPointer: diff.pointer,
|
||||
hunkIndex: hunkIndex,
|
||||
location: location.value,
|
||||
check: true,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue