refactor!: use Oid instead of String for arguments

This commit is contained in:
Aleksey Kulikov 2021-10-13 15:31:20 +03:00
parent 23787adc3a
commit 1972c6d1ab
39 changed files with 264 additions and 290 deletions

View file

@ -28,19 +28,19 @@ void main() {
hunks = [
{
'finalCommitId': 'fc38877b2552ab554752d9a77e1f48f738cca79b',
'finalCommitOid': 'fc38877b2552ab554752d9a77e1f48f738cca79b',
'finalStartLineNumber': 1,
'finalCommitter': sig1,
'originCommitId': 'fc38877b2552ab554752d9a77e1f48f738cca79b',
'originCommitOid': 'fc38877b2552ab554752d9a77e1f48f738cca79b',
'originStartLineNumber': 1,
'originCommitter': sig1,
'isBoundary': false,
},
{
'finalCommitId': 'a07a01e325c2c04e05d2450ad37785fbfe0a0014',
'finalCommitOid': 'a07a01e325c2c04e05d2450ad37785fbfe0a0014',
'finalStartLineNumber': 2,
'finalCommitter': sig2,
'originCommitId': 'a07a01e325c2c04e05d2450ad37785fbfe0a0014',
'originCommitOid': 'a07a01e325c2c04e05d2450ad37785fbfe0a0014',
'originStartLineNumber': 2,
'originCommitter': sig2,
'isBoundary': false,
@ -63,10 +63,10 @@ void main() {
for (var i = 0; i < blame.length; i++) {
expect(blame[i].linesCount, 1);
expect(blame[i].finalCommitId.sha, hunks[i]['finalCommitId']);
expect(blame[i].finalCommitOid.sha, hunks[i]['finalCommitOid']);
expect(blame[i].finalStartLineNumber, hunks[i]['finalStartLineNumber']);
expect(blame[i].finalCommitter, hunks[i]['finalCommitter']);
expect(blame[i].originCommitId.sha, hunks[i]['originCommitId']);
expect(blame[i].originCommitOid.sha, hunks[i]['originCommitOid']);
expect(
blame[i].originStartLineNumber,
hunks[i]['originStartLineNumber'],
@ -85,10 +85,10 @@ void main() {
final hunk = blame.forLine(1);
expect(hunk.linesCount, 1);
expect(hunk.finalCommitId.sha, hunks[0]['finalCommitId']);
expect(hunk.finalCommitOid.sha, hunks[0]['finalCommitOid']);
expect(hunk.finalStartLineNumber, hunks[0]['finalStartLineNumber']);
expect(hunk.finalCommitter, hunks[0]['finalCommitter']);
expect(hunk.originCommitId.sha, hunks[0]['originCommitId']);
expect(hunk.originCommitOid.sha, hunks[0]['originCommitOid']);
expect(
hunk.originStartLineNumber,
hunks[0]['originStartLineNumber'],
@ -117,13 +117,9 @@ void main() {
test(
'successfully gets the blame for provided file with newestCommit argument',
() {
final newestCommit = Oid.fromSHA(
repo: repo,
sha: 'fc38877b2552ab554752d9a77e1f48f738cca79b',
);
final blame = repo.blame(
path: 'feature_file',
newestCommit: newestCommit,
newestCommit: repo['fc38877b2552ab554752d9a77e1f48f738cca79b'],
flags: {GitBlameFlag.ignoreWhitespace},
);
@ -132,10 +128,10 @@ void main() {
final hunk = blame.first;
expect(hunk.linesCount, 1);
expect(hunk.finalCommitId.sha, hunks[0]['finalCommitId']);
expect(hunk.finalCommitOid.sha, hunks[0]['finalCommitOid']);
expect(hunk.finalStartLineNumber, hunks[0]['finalStartLineNumber']);
expect(hunk.finalCommitter, hunks[0]['finalCommitter']);
expect(hunk.originCommitId.sha, hunks[0]['originCommitId']);
expect(hunk.originCommitOid.sha, hunks[0]['originCommitOid']);
expect(
hunk.originStartLineNumber,
hunks[0]['originStartLineNumber'],

View file

@ -29,7 +29,7 @@ void main() {
});
test('returns correct values', () {
expect(blob.id.sha, blobSHA);
expect(blob.oid.sha, blobSHA);
expect(blob.isBinary, false);
expect(blob.size, 13);
expect(blob.content, blobContent);
@ -39,7 +39,7 @@ void main() {
final oid = repo.createBlob(newBlobContent);
final newBlob = repo.lookupBlob(oid);
expect(newBlob.id.sha, '18fdaeef018e57a92bcad2d4a35b577f34089af6');
expect(newBlob.oid.sha, '18fdaeef018e57a92bcad2d4a35b577f34089af6');
expect(newBlob.isBinary, false);
expect(newBlob.size, 9);
expect(newBlob.content, newBlobContent);
@ -52,7 +52,7 @@ void main() {
final oid = repo.createBlobFromWorkdir('feature_file');
final newBlob = repo.lookupBlob(oid);
expect(newBlob.id.sha, blobSHA);
expect(newBlob.oid.sha, blobSHA);
expect(newBlob.isBinary, false);
expect(newBlob.size, 13);
expect(newBlob.content, blobContent);

View file

@ -54,7 +54,7 @@ void main() {
);
final featureTree = featureHead.tree;
final repoHead = repo.head;
expect(repoHead.target.sha, featureHead.id.sha);
expect(repoHead.target, featureHead.oid);
expect(repo.status, isEmpty);
expect(
featureTree.entries.any((e) => e.name == 'another_feature_file'),

View file

@ -28,7 +28,7 @@ void main() {
mergeCommit = repo['78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8'];
tree = Tree.lookup(
repo: repo,
id: repo['7796359a96eb722939c24bafdb1afe9f07f2f628'],
oid: repo['7796359a96eb722939c24bafdb1afe9f07f2f628'],
);
});
@ -78,13 +78,13 @@ void main() {
final commit = repo.lookupCommit(oid);
expect(commit.id.sha, oid.sha);
expect(commit.oid, oid);
expect(commit.message, message);
expect(commit.messageEncoding, 'utf-8');
expect(commit.author, author);
expect(commit.committer, commiter);
expect(commit.time, 124);
expect(commit.tree.id, tree.id);
expect(commit.tree.oid, tree.oid);
expect(commit.parents.length, 1);
expect(commit.parents[0], mergeCommit);
@ -103,13 +103,13 @@ void main() {
final commit = repo.lookupCommit(oid);
expect(commit.id.sha, oid.sha);
expect(commit.oid, oid);
expect(commit.message, message);
expect(commit.messageEncoding, 'utf-8');
expect(commit.author, author);
expect(commit.committer, commiter);
expect(commit.time, 124);
expect(commit.tree.id, tree.id);
expect(commit.tree.oid, tree.oid);
expect(commit.parents.length, 0);
commit.free();
@ -132,16 +132,16 @@ void main() {
final commit = repo.lookupCommit(oid);
expect(commit.id.sha, oid.sha);
expect(commit.oid, oid);
expect(commit.message, message);
expect(commit.messageEncoding, 'utf-8');
expect(commit.author, author);
expect(commit.committer, commiter);
expect(commit.time, 124);
expect(commit.tree.id, tree.id);
expect(commit.tree.oid, tree.oid);
expect(commit.parents.length, 2);
expect(commit.parents[0], mergeCommit);
expect(commit.parents[1], parent2.id);
expect(commit.parents[1], parent2.oid);
parent1.free();
parent2.free();

View file

@ -218,7 +218,7 @@ index e69de29..c217c63 100644
final file = File('${tmpDir.path}/subdir/modified_file');
repo.reset(
target: 'a763aa560953e7cfb87ccbc2f536d665aa4dff22',
oid: repo['a763aa560953e7cfb87ccbc2f536d665aa4dff22'],
resetType: GitReset.hard,
);
expect(file.readAsStringSync(), '');
@ -280,11 +280,11 @@ index e69de29..c217c63 100644
expect(diff.deltas[0].oldFile.path, indexToWorkdir[0]);
expect(
diff.deltas[0].oldFile.id.sha,
diff.deltas[0].oldFile.oid.sha,
'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391',
);
expect(
diff.deltas[0].newFile.id.sha,
diff.deltas[0].newFile.oid.sha,
'0000000000000000000000000000000000000000',
);

View file

@ -54,15 +54,15 @@ void main() {
final entry = index['file'];
final otherEntry = index['feature_file'];
expect(entry.id == otherEntry.id, false);
expect(entry.oid == otherEntry.oid, false);
expect(entry.mode, isNot(GitFilemode.blobExecutable));
entry.path = 'some.txt';
entry.id = otherEntry.id;
entry.oid = otherEntry.oid;
entry.mode = GitFilemode.blobExecutable;
expect(entry.path, 'some.txt');
expect(entry.id == otherEntry.id, true);
expect(entry.oid == otherEntry.oid, true);
expect(entry.mode, GitFilemode.blobExecutable);
});

View file

@ -26,7 +26,7 @@ void main() {
repo['c68ff54aabf660fcdd9a2838d401583fe31249e3'],
);
final result = repo.mergeAnalysis(theirHead: commit.id);
final result = repo.mergeAnalysis(theirHead: commit.oid);
expect(result, [
{GitMergeAnalysis.upToDate},
GitMergePreference.none,
@ -42,7 +42,7 @@ void main() {
);
final result = repo.mergeAnalysis(
theirHead: commit.id,
theirHead: commit.oid,
ourRef: 'refs/tags/v0.1',
);
expect(result[0], {GitMergeAnalysis.upToDate});
@ -64,7 +64,7 @@ void main() {
);
final result = repo.mergeAnalysis(
theirHead: theirHead.id,
theirHead: theirHead.oid,
ourRef: 'refs/heads/${ffBranch.name}',
);
expect(
@ -83,7 +83,7 @@ void main() {
repo['5aecfa0fb97eadaac050ccb99f03c3fb65460ad4'],
);
final result = repo.mergeAnalysis(theirHead: commit.id);
final result = repo.mergeAnalysis(theirHead: commit.oid);
expect(result[0], {GitMergeAnalysis.normal});
expect(repo.status, isEmpty);
@ -192,7 +192,7 @@ conflict branch edit
expect(mergeIndex.conflicts, isEmpty);
final mergeCommitsTree = mergeIndex.writeTree(repo);
repo.merge(theirCommit.id);
repo.merge(theirCommit.oid);
final index = repo.index;
expect(index.conflicts, isEmpty);
final mergeTree = index.writeTree();
@ -263,7 +263,7 @@ conflict branch edit
repo['14905459d775f3f56a39ebc2ff081163f7da3529'],
);
final baseCommit = repo.lookupCommit(
repo.mergeBase(a: ourCommit.id.sha, b: theirCommit.id.sha),
repo.mergeBase(a: ourCommit.oid, b: theirCommit.oid),
);
final theirTree = theirCommit.tree;
final ourTree = ourCommit.tree;
@ -277,8 +277,8 @@ conflict branch edit
expect(mergeIndex.conflicts, isEmpty);
final mergeTreesTree = mergeIndex.writeTree(repo);
repo.setHead('14905459d775f3f56a39ebc2ff081163f7da3529');
repo.merge(theirCommit.id);
repo.setHead(ourCommit.oid);
repo.merge(theirCommit.oid);
final index = repo.index;
expect(index.conflicts, isEmpty);
final mergeTree = index.writeTree();
@ -303,7 +303,7 @@ conflict branch edit
repo['14905459d775f3f56a39ebc2ff081163f7da3529'],
);
final baseCommit = repo.lookupCommit(
repo.mergeBase(a: ourCommit.id.sha, b: theirCommit.id.sha),
repo.mergeBase(a: ourCommit.oid, b: theirCommit.oid),
);
final theirTree = theirCommit.tree;
final ourTree = ourCommit.tree;

View file

@ -8,14 +8,14 @@ void main() {
late Directory tmpDir;
const notesExpected = [
{
'id': 'd854ba919e1bb303f4d6bb4ca9a15c5cab2a2a50',
'oid': 'd854ba919e1bb303f4d6bb4ca9a15c5cab2a2a50',
'message': 'Another note\n',
'annotatedId': '78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8',
'annotatedOid': '78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8',
},
{
'id': 'd2ffe6b06b11dd90c2ee3f15d2c6b62f018554ed',
'oid': 'd2ffe6b06b11dd90c2ee3f15d2c6b62f018554ed',
'message': 'Note for HEAD\n',
'annotatedId': '821ed6e80627b8769d170a293862f9fc60825226',
'annotatedOid': '821ed6e80627b8769d170a293862f9fc60825226',
},
];
@ -36,20 +36,20 @@ void main() {
expect(notes.length, 2);
for (var i = 0; i < notes.length; i++) {
expect(notes[i].id.sha, notesExpected[i]['id']);
expect(notes[i].oid.sha, notesExpected[i]['oid']);
expect(notes[i].message, notesExpected[i]['message']);
expect(notes[i].annotatedId.sha, notesExpected[i]['annotatedId']);
expect(notes[i].annotatedOid.sha, notesExpected[i]['annotatedOid']);
notes[i].free();
}
});
test('successfully lookups note', () {
final head = repo.head;
final note = repo.lookupNote(annotatedId: head.target);
final note = repo.lookupNote(annotatedOid: head.target);
expect(note.id.sha, notesExpected[1]['id']);
expect(note.oid.sha, notesExpected[1]['oid']);
expect(note.message, notesExpected[1]['message']);
expect(note.annotatedId.sha, notesExpected[1]['annotatedId']);
expect(note.annotatedOid.sha, notesExpected[1]['annotatedOid']);
note.free();
head.free();
@ -61,7 +61,7 @@ void main() {
final noteOid = repo.createNote(
author: signature,
committer: signature,
annotatedId: head.target,
annotatedOid: head.target,
note: 'New note for HEAD',
force: true,
);
@ -80,13 +80,13 @@ void main() {
final head = repo.head;
repo.deleteNote(
annotatedId: repo.head.target,
annotatedOid: repo.head.target,
author: signature,
committer: signature,
);
expect(
() => repo.lookupNote(annotatedId: head.target),
() => repo.lookupNote(annotatedOid: head.target),
throwsA(isA<LibGit2Error>()),
);

View file

@ -48,7 +48,7 @@ void main() {
final odb = repo.odb;
final object = odb.read(oid);
expect(object.id, oid);
expect(object.oid, oid);
expect(object.type, GitObject.blob);
expect(object.data, blobContent);
expect(object.size, 13);

View file

@ -89,8 +89,8 @@ void main() {
final branches = repo.branches;
for (final branch in branches) {
final ref = repo.lookupReference('refs/heads/${branch.name}');
for (final commit in repo.log(sha: ref.target.sha)) {
packBuilder.addRecursively(commit.id);
for (final commit in repo.log(oid: ref.target)) {
packBuilder.addRecursively(commit.oid);
commit.free();
}
ref.free();

View file

@ -43,7 +43,7 @@ void main() {
for (var i = 0; i < operationsCount; i++) {
final operation = rebase.next();
expect(operation.type, GitRebaseOperation.pick);
expect(operation.id.sha, shas[i]);
expect(operation.oid.sha, shas[i]);
expect(operation.exec, '');
rebase.commit(committer: signature);
@ -74,7 +74,7 @@ void main() {
repo: repo,
branch: master.target,
onto: feature.target,
upstream: startCommit.id,
upstream: startCommit.oid,
);
final operationsCount = rebase.operationsCount;

View file

@ -343,23 +343,16 @@ void main() {
});
group('set target', () {
test('successfully sets with SHA hex', () {
test('successfully sets direct reference with provided Oid target', () {
final ref = repo.lookupReference('refs/heads/master');
ref.setTarget(target: newCommit);
ref.setTarget(target: repo[newCommit]);
expect(ref.target.sha, newCommit);
ref.free();
});
test('successfully sets target with short SHA hex', () {
final ref = repo.lookupReference('refs/heads/master');
ref.setTarget(target: newCommit.substring(0, 5));
expect(ref.target.sha, newCommit);
ref.free();
});
test('successfully sets symbolic target', () {
test('successfully sets symbolic target with provided reference name',
() {
final ref = repo.lookupReference('HEAD');
expect(ref.target.sha, lastCommit);
@ -474,7 +467,7 @@ void main() {
final commit = repo.lookupCommit(ref.target);
final peeled = ref.peel() as Commit;
expect(peeled.id, commit.id);
expect(peeled.oid, commit.oid);
peeled.free();
commit.free();
@ -488,8 +481,8 @@ void main() {
final peeledCommit = ref.peel(GitObject.commit) as Commit;
final peeledTree = ref.peel(GitObject.tree) as Tree;
expect(peeledCommit.id, commit.id);
expect(peeledTree.id, tree.id);
expect(peeledCommit.oid, commit.oid);
expect(peeledTree.oid, tree.oid);
peeledCommit.free();
commit.free();

View file

@ -356,7 +356,7 @@ Total 69 (delta 0), reused 1 (delta 0), pack-reused 68
remote.push(refspecs: ['refs/heads/master'], callbacks: callbacks);
expect(
originRepo.lookupCommit(originRepo.head.target).id.sha,
originRepo.lookupCommit(originRepo.head.target).oid.sha,
'821ed6e80627b8769d170a293862f9fc60825226',
);
expect(updateRefOutput, {'refs/heads/master': ''});

View file

@ -39,10 +39,10 @@ void main() {
'6cbc22e509d72758ab4c8d9f287ea846b90c448b',
'f17d0d48eae3aa08cecf29128a35e310c97b3521',
];
final commits = repo.log(sha: lastCommit);
final commits = repo.log(oid: repo[lastCommit]);
for (var i = 0; i < commits.length; i++) {
expect(commits[i].id.sha, log[i]);
expect(commits[i].oid.sha, log[i]);
}
for (final c in commits) {
@ -100,14 +100,7 @@ void main() {
test('successfully sets head when target is sha hex', () {
expect(repo.head.target.sha, lastCommit);
repo.setHead(featureCommit);
expect(repo.head.target.sha, featureCommit);
expect(repo.isHeadDetached, true);
});
test('successfully sets head when target is short sha hex', () {
expect(repo.head.target.sha, lastCommit);
repo.setHead(featureCommit.substring(0, 5));
repo.setHead(repo[featureCommit]);
expect(repo.head.target.sha, featureCommit);
expect(repo.isHeadDetached, true);
});
@ -176,11 +169,11 @@ void main() {
final tagger = newTag.tagger;
final newTagTarget = newTag.target as Commit;
expect(newTag.id.sha, '131a5eb6b7a880b5096c550ee7351aeae7b95a42');
expect(newTag.oid.sha, '131a5eb6b7a880b5096c550ee7351aeae7b95a42');
expect(newTag.name, tagName);
expect(newTag.message, message);
expect(tagger, signature);
expect(newTagTarget.id, target);
expect(newTagTarget.oid, target);
newTag.free();
newTagTarget.free();
@ -255,26 +248,15 @@ void main() {
final commit2 = repo.lookupCommit(repo['78b8bf12']);
expect(
repo.descendantOf(
commitSHA: commit1.id.sha,
ancestorSHA: commit2.id.sha,
),
repo.descendantOf(commit: commit1.oid, ancestor: commit2.oid),
true,
);
expect(
repo.descendantOf(
commitSHA: commit1.id.sha,
ancestorSHA: commit1.id.sha,
),
repo.descendantOf(commit: commit1.oid, ancestor: commit1.oid),
false,
);
expect(
repo.descendantOf(
commitSHA: commit2.id.sha,
ancestorSHA: commit1.id.sha,
),
repo.descendantOf(commit: commit2.oid, ancestor: commit1.oid),
false,
);
@ -287,15 +269,15 @@ void main() {
final commit2 = repo.lookupCommit(repo['c68ff54a']);
expect(
repo.aheadBehind(localSHA: commit1.id.sha, upstreamSHA: commit2.id.sha),
repo.aheadBehind(local: commit1.oid, upstream: commit2.oid),
[4, 0],
);
expect(
repo.aheadBehind(localSHA: commit2.id.sha, upstreamSHA: commit1.id.sha),
repo.aheadBehind(local: commit2.oid, upstream: commit1.oid),
[0, 4],
);
expect(
repo.aheadBehind(localSHA: commit1.id.sha, upstreamSHA: commit1.id.sha),
repo.aheadBehind(local: commit1.oid, upstream: commit1.oid),
[0, 0],
);

View file

@ -25,7 +25,7 @@ void main() {
var contents = file.readAsStringSync();
expect(contents, 'Feature edit\n');
repo.reset(target: sha, resetType: GitReset.hard);
repo.reset(oid: repo[sha], resetType: GitReset.hard);
contents = file.readAsStringSync();
expect(contents, isEmpty);
});
@ -34,7 +34,7 @@ void main() {
var contents = file.readAsStringSync();
expect(contents, 'Feature edit\n');
repo.reset(target: sha, resetType: GitReset.soft);
repo.reset(oid: repo[sha], resetType: GitReset.soft);
contents = file.readAsStringSync();
expect(contents, 'Feature edit\n');
@ -49,7 +49,7 @@ void main() {
var contents = file.readAsStringSync();
expect(contents, 'Feature edit\n');
repo.reset(target: sha, resetType: GitReset.mixed);
repo.reset(oid: repo[sha], resetType: GitReset.mixed);
contents = file.readAsStringSync();
expect(contents, 'Feature edit\n');

View file

@ -22,13 +22,13 @@ void main() {
group('revParse', () {
test('.single() returns commit with different spec strings', () {
final headCommit = repo.revParseSingle('HEAD');
expect(headCommit.id.sha, headSHA);
expect(headCommit.oid.sha, headSHA);
final parentCommit = repo.revParseSingle('HEAD^');
expect(parentCommit.id.sha, parentSHA);
expect(parentCommit.oid.sha, parentSHA);
final initCommit = repo.revParseSingle('@{-1}');
expect(initCommit.id.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
expect(initCommit.oid.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
headCommit.free();
parentCommit.free();
@ -39,7 +39,7 @@ void main() {
final masterRef = repo.lookupReference('refs/heads/master');
var headParse = repo.revParseExt('master');
expect(headParse.object.id.sha, headSHA);
expect(headParse.object.oid.sha, headSHA);
expect(headParse.reference, masterRef);
masterRef.free();
@ -50,7 +50,9 @@ void main() {
headParse = repo.revParseExt('feature');
expect(
headParse.object.id.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
headParse.object.oid.sha,
'5aecfa0fb97eadaac050ccb99f03c3fb65460ad4',
);
expect(headParse.reference, featureRef);
featureRef.free();
@ -61,7 +63,7 @@ void main() {
test('.ext() returns only commit when no intermidiate reference found', () {
final headParse = repo.revParseExt('HEAD^');
expect(headParse.object.id.sha, parentSHA);
expect(headParse.object.oid.sha, parentSHA);
expect(headParse.reference, isNull);
headParse.object.free();
@ -72,7 +74,7 @@ void main() {
() {
var revspec = repo.revParse('master');
expect(revspec.from.id.sha, headSHA);
expect(revspec.from.oid.sha, headSHA);
expect(revspec.to, isNull);
expect(revspec.flags, {GitRevSpec.single});
@ -80,8 +82,8 @@ void main() {
revspec = repo.revParse('HEAD^1..5aecfa');
expect(revspec.from.id.sha, parentSHA);
expect(revspec.to?.id.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
expect(revspec.from.oid.sha, parentSHA);
expect(revspec.to?.oid.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
expect(revspec.flags, {GitRevSpec.range});
revspec.from.free();
@ -89,11 +91,11 @@ void main() {
revspec = repo.revParse('HEAD...feature');
expect(revspec.from.id.sha, headSHA);
expect(revspec.to?.id.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
expect(revspec.from.oid.sha, headSHA);
expect(revspec.to?.oid.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
expect(revspec.flags, {GitRevSpec.range, GitRevSpec.mergeBase});
expect(
repo.mergeBase(a: revspec.from.id.sha, b: revspec.to!.id.sha),
repo.mergeBase(a: revspec.from.oid, b: revspec.to!.oid),
isA<Oid>(),
);

View file

@ -33,7 +33,7 @@ void main() {
final commits = walker.walk();
for (var i = 0; i < commits.length; i++) {
expect(commits[i].id.sha, log[i]);
expect(commits[i].oid.sha, log[i]);
}
for (final c in commits) {
@ -51,7 +51,7 @@ void main() {
final commits = walker.walk();
for (var i = 0; i < commits.length; i++) {
expect(commits[i].id.sha, log.reversed.toList()[i]);
expect(commits[i].oid.sha, log.reversed.toList()[i]);
}
for (final c in commits) {
@ -68,13 +68,13 @@ void main() {
final timeSortedCommits = walker.walk();
for (var i = 0; i < timeSortedCommits.length; i++) {
expect(timeSortedCommits[i].id.sha, log[i]);
expect(timeSortedCommits[i].oid.sha, log[i]);
}
walker.sorting({GitSort.time, GitSort.reverse});
final reverseSortedCommits = walker.walk();
for (var i = 0; i < reverseSortedCommits.length; i++) {
expect(reverseSortedCommits[i].id.sha, log.reversed.toList()[i]);
expect(reverseSortedCommits[i].oid.sha, log.reversed.toList()[i]);
}
for (final c in timeSortedCommits) {

View file

@ -33,9 +33,9 @@ void main() {
expect(submodule.path, testSubmodule);
expect(submodule.url, submoduleUrl);
expect(submodule.branch, '');
expect(submodule.headId?.sha, submoduleHeadSha);
expect(submodule.indexId?.sha, submoduleHeadSha);
expect(submodule.workdirId?.sha, null);
expect(submodule.headOid?.sha, submoduleHeadSha);
expect(submodule.indexOid?.sha, submoduleHeadSha);
expect(submodule.workdirOid?.sha, null);
expect(submodule.ignore, GitSubmoduleIgnore.none);
expect(submodule.updateRule, GitSubmoduleUpdate.checkout);

View file

@ -7,13 +7,13 @@ void main() {
late Repository repo;
late Tag tag;
late Directory tmpDir;
late Oid tagID;
late Oid tagOid;
setUp(() {
tmpDir = setupRepo(Directory('test/assets/testrepo/'));
repo = Repository.open(tmpDir.path);
tagID = repo['f0fdbf506397e9f58c59b88dfdd72778ec06cc0c'];
tag = repo.lookupTag(tagID);
tagOid = repo['f0fdbf506397e9f58c59b88dfdd72778ec06cc0c'];
tag = repo.lookupTag(tagOid);
});
tearDown(() {
@ -37,7 +37,7 @@ void main() {
final target = tag.target as Commit;
final tagger = tag.tagger;
expect(tag.id, tagID);
expect(tag.oid, tagOid);
expect(tag.name, 'v0.2');
expect(tag.message, 'annotated tag\n');
expect(target.message, 'add subdirectory file\n');
@ -69,11 +69,11 @@ void main() {
final tagger = newTag.tagger;
final newTagTarget = newTag.target as Commit;
expect(newTag.id.sha, '131a5eb6b7a880b5096c550ee7351aeae7b95a42');
expect(newTag.oid.sha, '131a5eb6b7a880b5096c550ee7351aeae7b95a42');
expect(newTag.name, tagName);
expect(newTag.message, message);
expect(tagger, signature);
expect(newTagTarget.id, target);
expect(newTagTarget.oid, target);
newTag.free();
newTagTarget.free();

View file

@ -30,13 +30,13 @@ void main() {
test('returns correct values', () {
expect(tree.length, 4);
expect(tree.entries.first.id.sha, fileSHA);
expect(tree.entries.first.oid.sha, fileSHA);
expect(tree.entries[0].name, '.gitignore');
expect(tree.entries[0].filemode, GitFilemode.blob);
});
test('returns tree entry with provided index position', () {
expect(tree[0].id.sha, fileSHA);
expect(tree[0].oid.sha, fileSHA);
});
test('throws when provided index position is outside of valid range', () {
@ -45,7 +45,7 @@ void main() {
});
test('returns tree entry with provided filename', () {
expect(tree['.gitignore'].id.sha, fileSHA);
expect(tree['.gitignore'].oid.sha, fileSHA);
});
test('throws when nothing found for provided filename', () {
@ -54,7 +54,7 @@ void main() {
test('returns tree entry with provided path to file', () {
final entry = tree['dir/dir_file.txt'];
expect(entry.id.sha, 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391');
expect(entry.oid.sha, 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391');
entry.free();
});
@ -77,7 +77,7 @@ void main() {
expect(newTree.length, 1);
expect(entry.name, 'filename');
expect(entry.filemode, GitFilemode.blob);
expect(entry.id, fileOid);
expect(entry.oid, fileOid);
builder.free();
entry.free();

View file

@ -33,7 +33,7 @@ void main() {
expect(builder, isA<TreeBuilder>());
expect(builder.length, tree.length);
expect(oid, tree.id);
expect(oid, tree.oid);
builder.free();
});
@ -56,7 +56,7 @@ void main() {
builder.add(
filename: entry.name,
oid: entry.id,
oid: entry.oid,
filemode: entry.filemode,
);
expect(builder[entry.name].name, entry.name);