feat(attr): add bindings and api

This commit is contained in:
Aleksey Kulikov 2021-09-30 13:53:58 +03:00
parent 934b601d68
commit ec80ad3dd4
5 changed files with 116 additions and 6 deletions

View file

@ -5,15 +5,15 @@ import 'package:libgit2dart/libgit2dart.dart';
void main() {
final cloneDir = Directory('${Directory.systemTemp.path}/credentials_cloned');
setUp(() async {
if (await cloneDir.exists()) {
cloneDir.delete(recursive: true);
setUp(() {
if (cloneDir.existsSync()) {
cloneDir.deleteSync(recursive: true);
}
});
tearDown(() async {
if (await cloneDir.exists()) {
cloneDir.delete(recursive: true);
tearDown(() {
if (cloneDir.existsSync()) {
cloneDir.deleteSync(recursive: true);
}
});
group('Credentials', () {

View file

@ -236,5 +236,20 @@ void main() {
signature.free();
config.free();
});
test('returns attribute value', () async {
expect(repo.getAttribute(path: 'invalid', name: 'not-there'), null);
final attrFile = await File('${repo.workdir}.gitattributes').create();
attrFile.writeAsString('*.dart text\n*.jpg -text\n*.sh eol=lf\n');
await File('${repo.workdir}file.dart').create();
await File('${repo.workdir}file.sh').create();
expect(repo.getAttribute(path: 'file.dart', name: 'not-there'), null);
expect(repo.getAttribute(path: 'file.dart', name: 'text'), true);
expect(repo.getAttribute(path: 'file.jpg', name: 'text'), false);
expect(repo.getAttribute(path: 'file.sh', name: 'eol'), 'lf');
});
});
}