mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat(repository): add ability to lookup different types of git objects with []
This commit is contained in:
parent
f19a34a768
commit
2cf974c624
14 changed files with 124 additions and 67 deletions
|
@ -21,7 +21,7 @@ void main() {
|
|||
to: await Directory(tmpDir).create(),
|
||||
);
|
||||
repo = Repository.open(tmpDir);
|
||||
blob = Blob.lookup(repo, Oid.fromSHA(repo, blobSHA));
|
||||
blob = Blob.lookup(repo, blobSHA);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
|
@ -44,7 +44,7 @@ void main() {
|
|||
|
||||
test('successfully creates new blob', () {
|
||||
final oid = Blob.create(repo, newBlobContent);
|
||||
final newBlob = Blob.lookup(repo, oid);
|
||||
final newBlob = Blob.lookup(repo, oid.sha);
|
||||
|
||||
expect(newBlob.id.sha, '18fdaeef018e57a92bcad2d4a35b577f34089af6');
|
||||
expect(newBlob.isBinary, false);
|
||||
|
@ -57,7 +57,7 @@ void main() {
|
|||
test('successfully creates new blob from file at provided relative path',
|
||||
() {
|
||||
final oid = Blob.createFromWorkdir(repo, 'feature_file');
|
||||
final newBlob = Blob.lookup(repo, oid);
|
||||
final newBlob = Blob.lookup(repo, oid.sha);
|
||||
|
||||
expect(newBlob.id.sha, blobSHA);
|
||||
expect(newBlob.isBinary, false);
|
||||
|
@ -89,7 +89,7 @@ void main() {
|
|||
final outsideFile =
|
||||
File('${Directory.current.absolute.path}/test/blob_test.dart');
|
||||
final oid = Blob.createFromDisk(repo, outsideFile.path);
|
||||
final newBlob = Blob.lookup(repo, oid);
|
||||
final newBlob = Blob.lookup(repo, oid.sha);
|
||||
|
||||
expect(newBlob, isA<Blob>());
|
||||
expect(newBlob.isBinary, false);
|
||||
|
|
|
@ -45,13 +45,13 @@ void main() {
|
|||
|
||||
group('Commit', () {
|
||||
test('successfully returns when 40 char sha hex is provided', () {
|
||||
final commit = repo[mergeCommit];
|
||||
final commit = repo[mergeCommit] as Commit;
|
||||
expect(commit, isA<Commit>());
|
||||
commit.free();
|
||||
});
|
||||
|
||||
test('successfully returns when sha hex is short', () {
|
||||
final commit = repo[mergeCommit.substring(0, 5)];
|
||||
final commit = repo[mergeCommit.substring(0, 5)] as Commit;
|
||||
expect(commit, isA<Commit>());
|
||||
commit.free();
|
||||
});
|
||||
|
@ -66,7 +66,7 @@ void main() {
|
|||
parents: [mergeCommit],
|
||||
);
|
||||
|
||||
final commit = repo[oid.sha];
|
||||
final commit = repo[oid.sha] as Commit;
|
||||
|
||||
expect(commit.id.sha, oid.sha);
|
||||
expect(commit.message, message);
|
||||
|
@ -91,7 +91,7 @@ void main() {
|
|||
parents: [],
|
||||
);
|
||||
|
||||
final commit = repo[oid.sha];
|
||||
final commit = repo[oid.sha] as Commit;
|
||||
|
||||
expect(commit.id.sha, oid.sha);
|
||||
expect(commit.message, message);
|
||||
|
@ -115,7 +115,7 @@ void main() {
|
|||
parents: [mergeCommit, 'fc38877b2552ab554752d9a77e1f48f738cca79b'],
|
||||
);
|
||||
|
||||
final commit = repo[oid.sha];
|
||||
final commit = repo[oid.sha] as Commit;
|
||||
|
||||
expect(commit.id.sha, oid.sha);
|
||||
expect(commit.message, message);
|
||||
|
@ -141,7 +141,7 @@ void main() {
|
|||
parents: [mergeCommit],
|
||||
);
|
||||
|
||||
final commit = repo[oid.sha];
|
||||
final commit = repo[oid.sha] as Commit;
|
||||
|
||||
expect(commit.id.sha, oid.sha);
|
||||
expect(commit.message, message);
|
||||
|
|
|
@ -275,7 +275,7 @@ void main() {
|
|||
|
||||
test('successfully creates new blob', () {
|
||||
final oid = repo.createBlob(newBlobContent);
|
||||
final newBlob = Blob.lookup(repo, oid);
|
||||
final newBlob = repo[oid.sha] as Blob;
|
||||
|
||||
expect(newBlob, isA<Blob>());
|
||||
|
||||
|
@ -286,7 +286,7 @@ void main() {
|
|||
'successfully creates new blob from file at provided relative path',
|
||||
() {
|
||||
final oid = repo.createBlobFromWorkdir('feature_file');
|
||||
final newBlob = Blob.lookup(repo, oid);
|
||||
final newBlob = repo[oid.sha] as Blob;
|
||||
|
||||
expect(newBlob, isA<Blob>());
|
||||
|
||||
|
@ -297,7 +297,7 @@ void main() {
|
|||
final outsideFile =
|
||||
File('${Directory.current.absolute.path}/test/blob_test.dart');
|
||||
final oid = repo.createBlobFromDisk(outsideFile.path);
|
||||
final newBlob = Blob.lookup(repo, oid);
|
||||
final newBlob = repo[oid.sha] as Blob;
|
||||
|
||||
expect(newBlob, isA<Blob>());
|
||||
|
||||
|
@ -320,12 +320,12 @@ void main() {
|
|||
repository: repo,
|
||||
tagName: tagName,
|
||||
target: target,
|
||||
targetType: GitObjectType.commit,
|
||||
targetType: GitObject.commit,
|
||||
tagger: signature,
|
||||
message: message,
|
||||
);
|
||||
|
||||
final newTag = Tag.lookup(repo, oid);
|
||||
final newTag = repo[oid.sha] as Tag;
|
||||
final tagger = newTag.tagger;
|
||||
final newTagTarget = newTag.target;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ void main() {
|
|||
to: await Directory(tmpDir).create(),
|
||||
);
|
||||
repo = Repository.open(tmpDir);
|
||||
tag = Tag.lookup(repo, Oid.fromSHA(repo, tagSHA));
|
||||
tag = Tag.lookup(repo, tagSHA);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
|
@ -68,12 +68,12 @@ void main() {
|
|||
repository: repo,
|
||||
tagName: tagName,
|
||||
target: target,
|
||||
targetType: GitObjectType.commit,
|
||||
targetType: GitObject.commit,
|
||||
tagger: signature,
|
||||
message: message,
|
||||
);
|
||||
|
||||
final newTag = Tag.lookup(repo, oid);
|
||||
final newTag = Tag.lookup(repo, oid.sha);
|
||||
final tagger = newTag.tagger;
|
||||
final newTagTarget = newTag.target;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ void main() {
|
|||
to: await Directory(tmpDir).create(),
|
||||
);
|
||||
repo = Repository.open(tmpDir);
|
||||
tree = Tree.lookup(repo, Oid.fromSHA(repo, treeSHA));
|
||||
tree = Tree.lookup(repo, treeSHA);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
|
@ -73,7 +73,7 @@ void main() {
|
|||
final builder = TreeBuilder(repo);
|
||||
|
||||
builder.add('filename', fileOid, GitFilemode.blob);
|
||||
final newTree = Tree.lookup(repo, builder.write());
|
||||
final newTree = Tree.lookup(repo, builder.write().sha);
|
||||
|
||||
final entry = newTree['filename'];
|
||||
expect(newTree.length, 1);
|
||||
|
|
|
@ -19,7 +19,7 @@ void main() {
|
|||
to: await Directory(tmpDir).create(),
|
||||
);
|
||||
repo = Repository.open(tmpDir);
|
||||
tree = Tree.lookup(repo, Oid.fromSHA(repo, treeSHA));
|
||||
tree = Tree.lookup(repo, treeSHA);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue