mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 20:59:08 -04:00
style: use Object instead of dynamic
This commit is contained in:
parent
1972c6d1ab
commit
beed516c89
13 changed files with 84 additions and 56 deletions
|
@ -10,7 +10,7 @@ import 'libgit2_bindings.dart';
|
|||
/// or a [String] value, if the attribute was set to an actual string.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
dynamic getAttribute({
|
||||
Object? getAttribute({
|
||||
required Pointer<git_repository> repoPointer,
|
||||
required int flags,
|
||||
required String path,
|
||||
|
|
|
@ -28,12 +28,15 @@ void head({
|
|||
final pathPointers = initOpts[1];
|
||||
final strArray = initOpts[2];
|
||||
|
||||
final error = libgit2.git_checkout_head(repoPointer, optsC);
|
||||
final error = libgit2.git_checkout_head(
|
||||
repoPointer,
|
||||
optsC as Pointer<git_checkout_options>,
|
||||
);
|
||||
|
||||
for (final p in pathPointers) {
|
||||
for (final p in pathPointers as List) {
|
||||
calloc.free(p);
|
||||
}
|
||||
calloc.free(strArray);
|
||||
calloc.free(strArray as Pointer);
|
||||
calloc.free(optsC);
|
||||
|
||||
if (error < 0) {
|
||||
|
@ -59,12 +62,16 @@ void index({
|
|||
final pathPointers = initOpts[1];
|
||||
final strArray = initOpts[2];
|
||||
|
||||
final error = libgit2.git_checkout_index(repoPointer, nullptr, optsC);
|
||||
final error = libgit2.git_checkout_index(
|
||||
repoPointer,
|
||||
nullptr,
|
||||
optsC as Pointer<git_checkout_options>,
|
||||
);
|
||||
|
||||
for (final p in pathPointers) {
|
||||
for (final p in pathPointers as List) {
|
||||
calloc.free(p);
|
||||
}
|
||||
calloc.free(strArray);
|
||||
calloc.free(strArray as Pointer);
|
||||
calloc.free(optsC);
|
||||
|
||||
if (error < 0) {
|
||||
|
@ -92,12 +99,16 @@ void tree({
|
|||
final pathPointers = initOpts[1];
|
||||
final strArray = initOpts[2];
|
||||
|
||||
final error = libgit2.git_checkout_tree(repoPointer, treeishPointer, optsC);
|
||||
final error = libgit2.git_checkout_tree(
|
||||
repoPointer,
|
||||
treeishPointer,
|
||||
optsC as Pointer<git_checkout_options>,
|
||||
);
|
||||
|
||||
for (final p in pathPointers) {
|
||||
for (final p in pathPointers as List) {
|
||||
calloc.free(p);
|
||||
}
|
||||
calloc.free(strArray);
|
||||
calloc.free(strArray as Pointer);
|
||||
calloc.free(optsC);
|
||||
|
||||
if (error < 0) {
|
||||
|
@ -105,12 +116,12 @@ void tree({
|
|||
}
|
||||
}
|
||||
|
||||
List<dynamic> initOptions({
|
||||
List<Object> initOptions({
|
||||
required int strategy,
|
||||
String? directory,
|
||||
List<String>? paths,
|
||||
}) {
|
||||
final optsC = calloc<git_checkout_options>(sizeOf<git_checkout_options>());
|
||||
final optsC = calloc<git_checkout_options>();
|
||||
libgit2.git_checkout_options_init(optsC, GIT_CHECKOUT_OPTIONS_VERSION);
|
||||
|
||||
optsC.ref.checkout_strategy = strategy;
|
||||
|
|
|
@ -10,7 +10,7 @@ import '../util.dart';
|
|||
/// you must call `free()` on the patch when done.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Map<String, dynamic> fromBuffers({
|
||||
Map<String, Pointer?> fromBuffers({
|
||||
String? oldBuffer,
|
||||
String? oldAsPath,
|
||||
String? newBuffer,
|
||||
|
@ -66,7 +66,7 @@ Map<String, dynamic> fromBuffers({
|
|||
/// must call `free()` on the patch when done.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Map<String, dynamic> fromBlobs({
|
||||
Map<String, Pointer?> fromBlobs({
|
||||
Pointer<git_blob>? oldBlobPointer,
|
||||
String? oldAsPath,
|
||||
Pointer<git_blob>? newBlobPointer,
|
||||
|
@ -114,7 +114,7 @@ Map<String, dynamic> fromBlobs({
|
|||
/// call `free()` on the patch when done.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Map<String, dynamic> fromBlobAndBuffer({
|
||||
Map<String, Pointer?> fromBlobAndBuffer({
|
||||
Pointer<git_blob>? oldBlobPointer,
|
||||
String? oldAsPath,
|
||||
String? buffer,
|
||||
|
@ -194,7 +194,7 @@ int numHunks(Pointer<git_patch> patch) => libgit2.git_patch_num_hunks(patch);
|
|||
/// Given a patch and a hunk index into the patch, this returns detailed information about that hunk.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Map<String, dynamic> hunk({
|
||||
Map<String, Object> hunk({
|
||||
required Pointer<git_patch> patchPointer,
|
||||
required int hunkIndex,
|
||||
}) {
|
||||
|
|
|
@ -374,7 +374,7 @@ void connect({
|
|||
/// remains available after disconnecting.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
List<Map<String, dynamic>> lsRemotes(Pointer<git_remote> remote) {
|
||||
List<Map<String, Object?>> lsRemotes(Pointer<git_remote> remote) {
|
||||
final out = calloc<Pointer<Pointer<git_remote_head>>>();
|
||||
final size = calloc<Uint64>();
|
||||
final error = libgit2.git_remote_ls(out, size, remote);
|
||||
|
@ -384,10 +384,10 @@ List<Map<String, dynamic>> lsRemotes(Pointer<git_remote> remote) {
|
|||
calloc.free(size);
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
} else {
|
||||
var result = <Map<String, dynamic>>[];
|
||||
var result = <Map<String, Object?>>[];
|
||||
|
||||
for (var i = 0; i < size.value; i++) {
|
||||
var remote = <String, dynamic>{};
|
||||
var remote = <String, Object?>{};
|
||||
Oid? loid;
|
||||
|
||||
final bool local = out[0][i].ref.local == 1 ? true : false;
|
||||
|
|
|
@ -72,10 +72,10 @@ void apply({
|
|||
|
||||
final error = libgit2.git_stash_apply(repoPointer, index, options);
|
||||
|
||||
for (final p in pathPointers) {
|
||||
for (final p in pathPointers as List) {
|
||||
calloc.free(p);
|
||||
}
|
||||
calloc.free(strArray);
|
||||
calloc.free(strArray as Pointer);
|
||||
calloc.free(optsC);
|
||||
calloc.free(options);
|
||||
|
||||
|
@ -127,10 +127,10 @@ void pop({
|
|||
|
||||
final error = libgit2.git_stash_pop(repoPointer, index, options);
|
||||
|
||||
for (final p in pathPointers) {
|
||||
for (final p in pathPointers as List) {
|
||||
calloc.free(p);
|
||||
}
|
||||
calloc.free(strArray);
|
||||
calloc.free(strArray as Pointer);
|
||||
calloc.free(optsC);
|
||||
calloc.free(options);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue