mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
refactor!: use named arguments if there is more than one
This commit is contained in:
parent
ec80ad3dd4
commit
5f7fdf4bd3
66 changed files with 1920 additions and 1136 deletions
|
@ -7,9 +7,12 @@ import '../util.dart';
|
|||
/// Lookup a blob object from a repository.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Pointer<git_blob> lookup(Pointer<git_repository> repo, Pointer<git_oid> id) {
|
||||
Pointer<git_blob> lookup({
|
||||
required Pointer<git_repository> repoPointer,
|
||||
required Pointer<git_oid> oidPointer,
|
||||
}) {
|
||||
final out = calloc<Pointer<git_blob>>();
|
||||
final error = libgit2.git_blob_lookup(out, repo, id);
|
||||
final error = libgit2.git_blob_lookup(out, repoPointer, oidPointer);
|
||||
|
||||
if (error < 0) {
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
|
@ -47,14 +50,15 @@ int size(Pointer<git_blob> blob) => libgit2.git_blob_rawsize(blob);
|
|||
/// Write content of a string buffer to the ODB as a blob.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Pointer<git_oid> create(
|
||||
Pointer<git_repository> repo,
|
||||
String buffer,
|
||||
int len,
|
||||
) {
|
||||
Pointer<git_oid> create({
|
||||
required Pointer<git_repository> repoPointer,
|
||||
required String buffer,
|
||||
required int len,
|
||||
}) {
|
||||
final out = calloc<git_oid>();
|
||||
final bufferC = buffer.toNativeUtf8().cast<Void>();
|
||||
final error = libgit2.git_blob_create_from_buffer(out, repo, bufferC, len);
|
||||
final error =
|
||||
libgit2.git_blob_create_from_buffer(out, repoPointer, bufferC, len);
|
||||
|
||||
calloc.free(bufferC);
|
||||
|
||||
|
@ -69,13 +73,14 @@ Pointer<git_oid> create(
|
|||
/// Object Database as a loose blob.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Pointer<git_oid> createFromWorkdir(
|
||||
Pointer<git_repository> repo,
|
||||
String relativePath,
|
||||
) {
|
||||
Pointer<git_oid> createFromWorkdir({
|
||||
required Pointer<git_repository> repoPointer,
|
||||
required String relativePath,
|
||||
}) {
|
||||
final out = calloc<git_oid>();
|
||||
final relativePathC = relativePath.toNativeUtf8().cast<Int8>();
|
||||
final error = libgit2.git_blob_create_from_workdir(out, repo, relativePathC);
|
||||
final error =
|
||||
libgit2.git_blob_create_from_workdir(out, repoPointer, relativePathC);
|
||||
|
||||
calloc.free(relativePathC);
|
||||
|
||||
|
@ -89,13 +94,13 @@ Pointer<git_oid> createFromWorkdir(
|
|||
/// Read a file from the filesystem and write its content to the Object Database as a loose blob.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Pointer<git_oid> createFromDisk(
|
||||
Pointer<git_repository> repo,
|
||||
String path,
|
||||
) {
|
||||
Pointer<git_oid> createFromDisk({
|
||||
required Pointer<git_repository> repoPointer,
|
||||
required String path,
|
||||
}) {
|
||||
final out = calloc<git_oid>();
|
||||
final pathC = path.toNativeUtf8().cast<Int8>();
|
||||
final error = libgit2.git_blob_create_from_disk(out, repo, pathC);
|
||||
final error = libgit2.git_blob_create_from_disk(out, repoPointer, pathC);
|
||||
|
||||
if (error < 0) {
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue