feat(commit): add binding and API method for git_revert (#30)

This commit is contained in:
Aleksey Kulikov 2021-12-23 11:40:29 +03:00 committed by GitHub
parent fda5173e7f
commit 74a20a9cf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 0 deletions

View file

@ -361,6 +361,21 @@ Pointer<git_tree> tree(Pointer<git_commit> commit) {
}
}
/// Reverts the given commit, producing changes in the index and working
/// directory.
///
/// Throws a [LibGit2Error] if error occured.
void revert({
required Pointer<git_repository> repoPointer,
required Pointer<git_commit> commitPointer,
}) {
final error = libgit2.git_revert(repoPointer, commitPointer, nullptr);
if (error < 0) {
throw LibGit2Error(libgit2.git_error_last());
}
}
/// Reverts the given commit against the given "our" commit, producing an index
/// that reflects the result of the revert.
///

View file

@ -665,6 +665,17 @@ class Repository {
);
}
/// Reverts the given [commit], producing changes in the index and working
/// directory.
///
/// Throws a [LibGit2Error] if error occured.
void revert(Commit commit) {
commit_bindings.revert(
repoPointer: _repoPointer,
commitPointer: commit.pointer,
);
}
/// Finds a single object and intermediate reference (if there is one) by a
/// [spec] revision string.
///