mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat(packbuilder): add more bindings and API methods (#25)
This commit is contained in:
parent
9791b6324c
commit
50a6087a5b
4 changed files with 173 additions and 7 deletions
|
@ -41,6 +41,41 @@ class PackBuilder {
|
|||
);
|
||||
}
|
||||
|
||||
/// Adds a commit object.
|
||||
///
|
||||
/// This will add a commit as well as the completed referenced tree.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
void addCommit(Oid oid) {
|
||||
bindings.addCommit(
|
||||
packbuilderPointer: _packbuilderPointer,
|
||||
oidPointer: oid.pointer,
|
||||
);
|
||||
}
|
||||
|
||||
/// Adds a root tree object.
|
||||
///
|
||||
/// This will add the tree as well as all referenced trees and blobs.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
void addTree(Oid oid) {
|
||||
bindings.addTree(
|
||||
packbuilderPointer: _packbuilderPointer,
|
||||
oidPointer: oid.pointer,
|
||||
);
|
||||
}
|
||||
|
||||
/// Adds objects as given by the walker.
|
||||
///
|
||||
/// Those commits and all objects they reference will be inserted into the
|
||||
/// packbuilder.
|
||||
void addWalk(RevWalk walker) {
|
||||
bindings.addWalk(
|
||||
packbuilderPointer: _packbuilderPointer,
|
||||
walkerPointer: walker.pointer,
|
||||
);
|
||||
}
|
||||
|
||||
/// Writes the new pack and corresponding index file to [path] if provided
|
||||
/// or default location.
|
||||
///
|
||||
|
@ -55,6 +90,12 @@ class PackBuilder {
|
|||
/// Number of objects the packbuilder has already written out.
|
||||
int get writtenLength => bindings.writtenCount(_packbuilderPointer);
|
||||
|
||||
/// Packfile's hash.
|
||||
///
|
||||
/// A packfile's name is derived from the sorted hashing of all object names.
|
||||
/// This is only correct after the packfile has been written.
|
||||
Oid get hash => Oid(bindings.hash(_packbuilderPointer));
|
||||
|
||||
/// Sets and returns the number of threads to spawn.
|
||||
///
|
||||
/// By default, libgit2 won't spawn any threads at all. When set to 0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue