mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat(diff): add ability to get patchid
This commit is contained in:
parent
a7b714c2f3
commit
f7f4a395c0
3 changed files with 34 additions and 0 deletions
|
@ -75,6 +75,18 @@ class Diff {
|
|||
);
|
||||
}
|
||||
|
||||
/// Calculate the patch ID for the given patch.
|
||||
///
|
||||
/// Calculate a stable patch ID for the given patch by summing the hash of the file diffs,
|
||||
/// ignoring whitespace and line numbers. This can be used to derive whether two diffs are
|
||||
/// the same with a high probability.
|
||||
///
|
||||
/// Currently, this function only calculates stable patch IDs, as defined in `git-patch-id(1)`,
|
||||
/// and should in fact generate the same IDs as the upstream git project does.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Oid get patchId => Oid(bindings.patchId(_diffPointer));
|
||||
|
||||
/// Releases memory allocated for diff object.
|
||||
void free() => bindings.free(_diffPointer);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue