test: disable repository owner verification for tests (#47)

This commit is contained in:
Aleksey Kulikov 2022-04-13 14:02:26 +03:00 committed by GitHub
parent f42f8a6e1b
commit 94c40f9a94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 4 deletions

View file

@ -2,6 +2,7 @@ import 'dart:ffi';
import 'package:ffi/ffi.dart';
import 'package:libgit2dart/libgit2dart.dart';
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
import 'package:libgit2dart/src/util.dart';
class Libgit2 {
@ -33,4 +34,25 @@ class Libgit2 {
.where((e) => featuresInt & e.value == e.value)
.toSet();
}
/// Returns owner validation setting for repository directories.
static bool get ownerValidation {
libgit2.git_libgit2_init();
final out = calloc<Int8>();
libgit2.git_libgit2_opts(
git_libgit2_opt_t.GIT_OPT_GET_OWNER_VALIDATION,
out,
);
return out.value == 1 || false;
}
/// Sets owner validation setting for repository directories.
static set ownerValidation(bool value) {
libgit2.git_libgit2_init();
final valueC = value ? 1 : 0;
libgit2.git_libgit2_opts_set(
git_libgit2_opt_t.GIT_OPT_SET_OWNER_VALIDATION,
valueC,
);
}
}