mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 12:49:08 -04:00
feat(diff): add ability to apply diff
This commit is contained in:
parent
344dba60e9
commit
cd9f38c2bd
4 changed files with 89 additions and 0 deletions
|
@ -798,4 +798,25 @@ class Repository {
|
|||
}) {
|
||||
return a.diff(newBlob: b, oldAsPath: aPath, newAsPath: bPath);
|
||||
}
|
||||
|
||||
/// Applies the [diff] to the given repository, making changes directly in the working directory.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
void apply(Diff diff) {
|
||||
diff_bindings.apply(
|
||||
_repoPointer,
|
||||
diff.pointer,
|
||||
GitApplyLocation.workdir.value,
|
||||
);
|
||||
}
|
||||
|
||||
/// Checks if the [diff] will apply to HEAD.
|
||||
bool applies(Diff diff) {
|
||||
return diff_bindings.apply(
|
||||
_repoPointer,
|
||||
diff.pointer,
|
||||
GitApplyLocation.index.value,
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue