mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 12:49:08 -04:00
refactor: use loops inside list literals
This commit is contained in:
parent
c35d336a56
commit
5c9c23f9f5
13 changed files with 65 additions and 106 deletions
|
@ -13,10 +13,10 @@ List<String> list(Pointer<git_repository> repo) {
|
|||
final out = calloc<git_strarray>();
|
||||
libgit2.git_remote_list(out, repo);
|
||||
|
||||
final result = <String>[];
|
||||
for (var i = 0; i < out.ref.count; i++) {
|
||||
result.add(out.ref.strings[i].cast<Utf8>().toDartString());
|
||||
}
|
||||
final result = <String>[
|
||||
for (var i = 0; i < out.ref.count; i++)
|
||||
out.ref.strings[i].cast<Utf8>().toDartString()
|
||||
];
|
||||
|
||||
calloc.free(out);
|
||||
|
||||
|
@ -162,11 +162,13 @@ List<String> rename({
|
|||
calloc.free(out);
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
} else {
|
||||
final result = <String>[];
|
||||
for (var i = 0; i < out.ref.count; i++) {
|
||||
result.add(out.ref.strings[i].cast<Utf8>().toDartString());
|
||||
}
|
||||
final result = <String>[
|
||||
for (var i = 0; i < out.ref.count; i++)
|
||||
out.ref.strings[i].cast<Utf8>().toDartString()
|
||||
];
|
||||
|
||||
calloc.free(out);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -253,11 +255,13 @@ List<String> fetchRefspecs(Pointer<git_remote> remote) {
|
|||
final out = calloc<git_strarray>();
|
||||
libgit2.git_remote_get_fetch_refspecs(out, remote);
|
||||
|
||||
final result = <String>[];
|
||||
for (var i = 0; i < out.ref.count; i++) {
|
||||
result.add(out.ref.strings[i].cast<Utf8>().toDartString());
|
||||
}
|
||||
final result = <String>[
|
||||
for (var i = 0; i < out.ref.count; i++)
|
||||
out.ref.strings[i].cast<Utf8>().toDartString()
|
||||
];
|
||||
|
||||
calloc.free(out);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -266,11 +270,13 @@ List<String> pushRefspecs(Pointer<git_remote> remote) {
|
|||
final out = calloc<git_strarray>();
|
||||
libgit2.git_remote_get_push_refspecs(out, remote);
|
||||
|
||||
final result = <String>[];
|
||||
for (var i = 0; i < out.ref.count; i++) {
|
||||
result.add(out.ref.strings[i].cast<Utf8>().toDartString());
|
||||
}
|
||||
final result = <String>[
|
||||
for (var i = 0; i < out.ref.count; i++)
|
||||
out.ref.strings[i].cast<Utf8>().toDartString()
|
||||
];
|
||||
|
||||
calloc.free(out);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,6 @@ Pointer<git_repository> clone({
|
|||
required String localPath,
|
||||
required bool bare,
|
||||
RemoteCallback? remoteCallback,
|
||||
// Repository Function(String, bool)? repository,
|
||||
RepositoryCallback? repositoryCallback,
|
||||
String? checkoutBranch,
|
||||
required Callbacks callbacks,
|
||||
|
|
|
@ -110,11 +110,13 @@ List<String> list(Pointer<git_repository> repo) {
|
|||
calloc.free(out);
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
} else {
|
||||
final result = <String>[];
|
||||
for (var i = 0; i < out.ref.count; i++) {
|
||||
result.add(out.ref.strings[i].cast<Utf8>().toDartString());
|
||||
}
|
||||
final result = <String>[
|
||||
for (var i = 0; i < out.ref.count; i++)
|
||||
out.ref.strings[i].cast<Utf8>().toDartString()
|
||||
];
|
||||
|
||||
calloc.free(out);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue