mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
feat(blob): add more bindings and API methods (#21)
This commit is contained in:
parent
39a71811cb
commit
e6bfdc5a85
423 changed files with 1076 additions and 39 deletions
|
@ -14,7 +14,7 @@ void main() {
|
|||
const newBlobContent = 'New blob\n';
|
||||
|
||||
setUp(() {
|
||||
tmpDir = setupRepo(Directory('test/assets/testrepo/'));
|
||||
tmpDir = setupRepo(Directory('test/assets/attributes_repo/'));
|
||||
repo = Repository.open(tmpDir.path);
|
||||
});
|
||||
|
||||
|
@ -107,6 +107,55 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
test('duplicates blob', () {
|
||||
final blob = repo.lookupBlob(repo[blobSHA]);
|
||||
final dupBlob = blob.duplicate();
|
||||
|
||||
expect(blob.oid.sha, dupBlob.oid.sha);
|
||||
|
||||
dupBlob.free();
|
||||
blob.free();
|
||||
});
|
||||
|
||||
test('filters content of a blob', () {
|
||||
final blobOid = repo.createBlob('clrf\nclrf\n');
|
||||
final blob = repo.lookupBlob(blobOid);
|
||||
|
||||
expect(blob.filterContent(asPath: 'file.crlf'), 'clrf\r\nclrf\r\n');
|
||||
|
||||
blob.free();
|
||||
});
|
||||
|
||||
test('filters content of a blob with provided commit for attributes', () {
|
||||
repo.checkout(refName: 'refs/tags/v0.2');
|
||||
|
||||
final blobOid = repo.createBlob('clrf\nclrf\n');
|
||||
final blob = repo.lookupBlob(blobOid);
|
||||
|
||||
final commit = repo.lookupCommit(
|
||||
repo['d2f3abc9324a22a9f80fec2c131ec43c93430618'],
|
||||
);
|
||||
|
||||
expect(
|
||||
blob.filterContent(
|
||||
asPath: 'file.crlf',
|
||||
flags: {GitBlobFilter.attributesFromCommit},
|
||||
attributesCommit: commit,
|
||||
),
|
||||
'clrf\r\nclrf\r\n',
|
||||
);
|
||||
|
||||
commit.free();
|
||||
blob.free();
|
||||
});
|
||||
|
||||
test('throws when trying to filter content of a blob and error occurs', () {
|
||||
expect(
|
||||
() => Blob(nullptr).filterContent(asPath: ''),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
});
|
||||
|
||||
group('diff', () {
|
||||
const path = 'feature_file';
|
||||
const blobPatch = """
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue