mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
test: remove unnecessary variables declarations
This commit is contained in:
parent
76b8de1f80
commit
28f08e308a
23 changed files with 416 additions and 492 deletions
|
@ -39,14 +39,15 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates annotated commit from provided reference', () {
|
test('creates annotated commit from provided reference', () {
|
||||||
final reference = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
const refName = 'refs/heads/master';
|
||||||
|
final reference = Reference.lookup(repo: repo, name: refName);
|
||||||
final annotated = AnnotatedCommit.fromReference(
|
final annotated = AnnotatedCommit.fromReference(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
reference: reference,
|
reference: reference,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(annotated.oid, reference.target);
|
expect(annotated.oid, reference.target);
|
||||||
expect(annotated.refName, 'refs/heads/master');
|
expect(annotated.refName, refName);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
|
|
|
@ -88,11 +88,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checks if branch is current head', () {
|
test('checks if branch is current head', () {
|
||||||
final masterBranch = Branch.lookup(repo: repo, name: 'master');
|
expect(Branch.lookup(repo: repo, name: 'master').isHead, true);
|
||||||
final featureBranch = Branch.lookup(repo: repo, name: 'feature');
|
expect(Branch.lookup(repo: repo, name: 'feature').isHead, false);
|
||||||
|
|
||||||
expect(masterBranch.isHead, true);
|
|
||||||
expect(featureBranch.isHead, false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when checking if branch is current head and error occurs', () {
|
test('throws when checking if branch is current head and error occurs', () {
|
||||||
|
@ -103,11 +100,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checks if branch is checked out', () {
|
test('checks if branch is checked out', () {
|
||||||
final masterBranch = Branch.lookup(repo: repo, name: 'master');
|
expect(Branch.lookup(repo: repo, name: 'master').isCheckedOut, true);
|
||||||
final featureBranch = Branch.lookup(repo: repo, name: 'feature');
|
expect(Branch.lookup(repo: repo, name: 'feature').isCheckedOut, false);
|
||||||
|
|
||||||
expect(masterBranch.isCheckedOut, true);
|
|
||||||
expect(featureBranch.isCheckedOut, false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when checking if branch is checked out and error occurs', () {
|
test('throws when checking if branch is checked out and error occurs', () {
|
||||||
|
@ -118,8 +112,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns name', () {
|
test('returns name', () {
|
||||||
final branch = Branch.lookup(repo: repo, name: 'master');
|
expect(Branch.lookup(repo: repo, name: 'master').name, 'master');
|
||||||
expect(branch.name, 'master');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when getting name and error occurs', () {
|
test('throws when getting name and error occurs', () {
|
||||||
|
@ -134,13 +127,14 @@ void main() {
|
||||||
test(
|
test(
|
||||||
'throws when getting remote name of a remote-tracking branch and '
|
'throws when getting remote name of a remote-tracking branch and '
|
||||||
'error occurs', () {
|
'error occurs', () {
|
||||||
final branch = Branch.lookup(repo: repo, name: 'master');
|
expect(
|
||||||
expect(() => branch.remoteName, throwsA(isA<LibGit2Error>()));
|
() => Branch.lookup(repo: repo, name: 'master').remoteName,
|
||||||
|
throwsA(isA<LibGit2Error>()),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns upstream of a local branch', () {
|
test('returns upstream of a local branch', () {
|
||||||
final branch = Branch.lookup(repo: repo, name: 'master');
|
final upstream = Branch.lookup(repo: repo, name: 'master').upstream;
|
||||||
final upstream = branch.upstream;
|
|
||||||
|
|
||||||
expect(upstream.isRemote, true);
|
expect(upstream.isRemote, true);
|
||||||
expect(upstream.name, 'refs/remotes/origin/master');
|
expect(upstream.name, 'refs/remotes/origin/master');
|
||||||
|
@ -182,29 +176,41 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns upstream name of a local branch', () {
|
test('returns upstream name of a local branch', () {
|
||||||
final branch = Branch.lookup(repo: repo, name: 'master');
|
expect(
|
||||||
expect(branch.upstreamName, 'refs/remotes/origin/master');
|
Branch.lookup(repo: repo, name: 'master').upstreamName,
|
||||||
|
'refs/remotes/origin/master',
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to get upstream name of a branch and error occurs',
|
test('throws when trying to get upstream name of a branch and error occurs',
|
||||||
() {
|
() {
|
||||||
final branch = Branch.lookup(repo: repo, name: 'feature');
|
expect(
|
||||||
expect(() => branch.upstreamName, throwsA(isA<LibGit2Error>()));
|
() => Branch.lookup(repo: repo, name: 'feature').upstreamName,
|
||||||
|
throwsA(isA<LibGit2Error>()),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns upstream remote of a local branch', () {
|
test('returns upstream remote of a local branch', () {
|
||||||
final branch = Branch.lookup(repo: repo, name: 'master');
|
expect(
|
||||||
expect(branch.upstreamRemote, 'origin');
|
Branch.lookup(repo: repo, name: 'master').upstreamRemote,
|
||||||
|
'origin',
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to get upstream remote of a remote branch', () {
|
test('throws when trying to get upstream remote of a remote branch', () {
|
||||||
final branch = Branch.list(repo: repo, type: GitBranch.remote).first;
|
expect(
|
||||||
expect(() => branch.upstreamRemote, throwsA(isA<LibGit2Error>()));
|
() => Branch.list(repo: repo, type: GitBranch.remote)
|
||||||
|
.first
|
||||||
|
.upstreamRemote,
|
||||||
|
throwsA(isA<LibGit2Error>()),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns upstream merge of a local branch', () {
|
test('returns upstream merge of a local branch', () {
|
||||||
final branch = Branch.lookup(repo: repo, name: 'master');
|
expect(
|
||||||
expect(branch.upstreamMerge, 'refs/heads/master');
|
Branch.lookup(repo: repo, name: 'master').upstreamMerge,
|
||||||
|
'refs/heads/master',
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to get upstream merge of a remote branch', () {
|
test('throws when trying to get upstream merge of a remote branch', () {
|
||||||
|
@ -219,9 +225,8 @@ void main() {
|
||||||
name: 'testing',
|
name: 'testing',
|
||||||
target: Commit.lookup(repo: repo, oid: lastCommit),
|
target: Commit.lookup(repo: repo, oid: lastCommit),
|
||||||
);
|
);
|
||||||
final branches = Branch.list(repo: repo);
|
|
||||||
|
|
||||||
expect(branches.length, 4);
|
expect(Branch.list(repo: repo).length, 4);
|
||||||
expect(branch.target, lastCommit);
|
expect(branch.target, lastCommit);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -241,9 +246,8 @@ void main() {
|
||||||
target: Commit.lookup(repo: repo, oid: lastCommit),
|
target: Commit.lookup(repo: repo, oid: lastCommit),
|
||||||
force: true,
|
force: true,
|
||||||
);
|
);
|
||||||
final localBranches = Branch.list(repo: repo, type: GitBranch.local);
|
|
||||||
|
|
||||||
expect(localBranches.length, 2);
|
expect(Branch.list(repo: repo, type: GitBranch.local).length, 2);
|
||||||
expect(branch.target, lastCommit);
|
expect(branch.target, lastCommit);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -269,15 +273,16 @@ void main() {
|
||||||
group('rename()', () {
|
group('rename()', () {
|
||||||
test('renames branch', () {
|
test('renames branch', () {
|
||||||
Branch.rename(repo: repo, oldName: 'feature', newName: 'renamed');
|
Branch.rename(repo: repo, oldName: 'feature', newName: 'renamed');
|
||||||
final branch = Branch.lookup(repo: repo, name: 'renamed');
|
|
||||||
final branches = Branch.list(repo: repo);
|
|
||||||
|
|
||||||
expect(branches.length, 3);
|
expect(Branch.list(repo: repo).length, 3);
|
||||||
expect(
|
expect(
|
||||||
() => Branch.lookup(repo: repo, name: 'feature'),
|
() => Branch.lookup(repo: repo, name: 'feature'),
|
||||||
throwsA(isA<LibGit2Error>()),
|
throwsA(isA<LibGit2Error>()),
|
||||||
);
|
);
|
||||||
expect(branch.target, featureCommit);
|
expect(
|
||||||
|
Branch.lookup(repo: repo, name: 'renamed').target,
|
||||||
|
featureCommit,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when name already exists', () {
|
test('throws when name already exists', () {
|
||||||
|
@ -298,9 +303,8 @@ void main() {
|
||||||
newName: 'feature',
|
newName: 'feature',
|
||||||
force: true,
|
force: true,
|
||||||
);
|
);
|
||||||
final branch = Branch.lookup(repo: repo, name: 'feature');
|
|
||||||
|
|
||||||
expect(branch.target, lastCommit);
|
expect(Branch.lookup(repo: repo, name: 'feature').target, lastCommit);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when name is invalid', () {
|
test('throws when name is invalid', () {
|
||||||
|
|
|
@ -72,8 +72,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checkouts reference', () {
|
test('checkouts reference', () {
|
||||||
final masterHead = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
final masterTree = Commit.lookup(repo: repo, oid: repo['821ed6e']).tree;
|
||||||
final masterTree = masterHead.tree;
|
|
||||||
expect(
|
expect(
|
||||||
masterTree.entries.any((e) => e.name == 'another_feature_file'),
|
masterTree.entries.any((e) => e.name == 'another_feature_file'),
|
||||||
false,
|
false,
|
||||||
|
@ -82,9 +81,8 @@ void main() {
|
||||||
Checkout.reference(repo: repo, name: 'refs/heads/feature');
|
Checkout.reference(repo: repo, name: 'refs/heads/feature');
|
||||||
final featureHead = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
final featureHead = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
final featureTree = featureHead.tree;
|
final featureTree = featureHead.tree;
|
||||||
final repoHead = repo.head;
|
|
||||||
// does not change HEAD
|
// does not change HEAD
|
||||||
expect(repoHead.target, isNot(featureHead.oid));
|
expect(repo.head.target, isNot(featureHead.oid));
|
||||||
expect(
|
expect(
|
||||||
featureTree.entries.any((e) => e.name == 'another_feature_file'),
|
featureTree.entries.any((e) => e.name == 'another_feature_file'),
|
||||||
true,
|
true,
|
||||||
|
@ -105,16 +103,14 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checkouts commit', () {
|
test('checkouts commit', () {
|
||||||
final index = repo.index;
|
expect(repo.index.find('another_feature_file'), equals(false));
|
||||||
expect(index.find('another_feature_file'), equals(false));
|
|
||||||
|
|
||||||
final featureHead = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
final featureHead = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
Checkout.commit(repo: repo, commit: featureHead);
|
Checkout.commit(repo: repo, commit: featureHead);
|
||||||
|
|
||||||
final repoHead = repo.head;
|
|
||||||
// does not change HEAD
|
// does not change HEAD
|
||||||
expect(repoHead.target, isNot(featureHead.oid));
|
expect(repo.head.target, isNot(featureHead.oid));
|
||||||
expect(index.find('another_feature_file'), equals(true));
|
expect(repo.index.find('another_feature_file'), equals(true));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checkouts commit with provided path', () {
|
test('checkouts commit with provided path', () {
|
||||||
|
@ -125,9 +121,8 @@ void main() {
|
||||||
paths: ['another_feature_file'],
|
paths: ['another_feature_file'],
|
||||||
);
|
);
|
||||||
|
|
||||||
final repoHead = repo.head;
|
|
||||||
// does not change HEAD
|
// does not change HEAD
|
||||||
expect(repoHead.target, isNot(featureHead.oid));
|
expect(repo.head.target, isNot(featureHead.oid));
|
||||||
expect(
|
expect(
|
||||||
repo.status,
|
repo.status,
|
||||||
{
|
{
|
||||||
|
@ -191,8 +186,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('performs dry run checkout', () {
|
test('performs dry run checkout', () {
|
||||||
final index = repo.index;
|
expect(repo.index.length, 4);
|
||||||
expect(index.length, 4);
|
|
||||||
final file = File(p.join(repo.workdir, 'another_feature_file'));
|
final file = File(p.join(repo.workdir, 'another_feature_file'));
|
||||||
expect(file.existsSync(), false);
|
expect(file.existsSync(), false);
|
||||||
|
|
||||||
|
@ -201,7 +195,7 @@ void main() {
|
||||||
name: 'refs/heads/feature',
|
name: 'refs/heads/feature',
|
||||||
strategy: {GitCheckout.dryRun},
|
strategy: {GitCheckout.dryRun},
|
||||||
);
|
);
|
||||||
expect(index.length, 4);
|
expect(repo.index.length, 4);
|
||||||
expect(file.existsSync(), false);
|
expect(file.existsSync(), false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -58,14 +58,13 @@ void main() {
|
||||||
|
|
||||||
test('reverts commit affecting index and workdir', () {
|
test('reverts commit affecting index and workdir', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
final commit = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
||||||
final index = repo.index;
|
|
||||||
final file = File(p.join(repo.workdir, 'dir', 'dir_file.txt'));
|
final file = File(p.join(repo.workdir, 'dir', 'dir_file.txt'));
|
||||||
expect(index.find('dir/dir_file.txt'), true);
|
expect(repo.index.find('dir/dir_file.txt'), true);
|
||||||
expect(file.existsSync(), true);
|
expect(file.existsSync(), true);
|
||||||
|
|
||||||
commit.revert();
|
commit.revert();
|
||||||
|
|
||||||
expect(index.find('dir/dir_file.txt'), false);
|
expect(repo.index.find('dir/dir_file.txt'), false);
|
||||||
expect(file.existsSync(), false);
|
expect(file.existsSync(), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -74,14 +73,14 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reverts commit to provided commit', () {
|
test('reverts commit to provided commit', () {
|
||||||
final to = Commit.lookup(repo: repo, oid: repo['78b8bf1']);
|
|
||||||
final from = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
|
||||||
final index = repo.index;
|
|
||||||
final file = File(p.join(repo.workdir, 'dir', 'dir_file.txt'));
|
final file = File(p.join(repo.workdir, 'dir', 'dir_file.txt'));
|
||||||
expect(index.find('dir/dir_file.txt'), true);
|
expect(repo.index.find('dir/dir_file.txt'), true);
|
||||||
expect(file.existsSync(), true);
|
expect(file.existsSync(), true);
|
||||||
|
|
||||||
final revertIndex = from.revertTo(commit: to);
|
final from = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
||||||
|
final revertIndex = from.revertTo(
|
||||||
|
commit: Commit.lookup(repo: repo, oid: repo['78b8bf1']),
|
||||||
|
);
|
||||||
expect(revertIndex.find('dir/dir_file.txt'), false);
|
expect(revertIndex.find('dir/dir_file.txt'), false);
|
||||||
expect(file.existsSync(), true);
|
expect(file.existsSync(), true);
|
||||||
});
|
});
|
||||||
|
@ -104,7 +103,6 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates commit', () {
|
test('creates commit', () {
|
||||||
final parent = Commit.lookup(repo: repo, oid: tip);
|
|
||||||
final oid = Commit.create(
|
final oid = Commit.create(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
updateRef: 'HEAD',
|
updateRef: 'HEAD',
|
||||||
|
@ -112,7 +110,7 @@ void main() {
|
||||||
author: author,
|
author: author,
|
||||||
committer: committer,
|
committer: committer,
|
||||||
tree: tree,
|
tree: tree,
|
||||||
parents: [parent],
|
parents: [Commit.lookup(repo: repo, oid: tip)],
|
||||||
);
|
);
|
||||||
|
|
||||||
final commit = Commit.lookup(repo: repo, oid: oid);
|
final commit = Commit.lookup(repo: repo, oid: oid);
|
||||||
|
@ -157,7 +155,6 @@ Some description.
|
||||||
});
|
});
|
||||||
|
|
||||||
test('writes commit into the buffer', () {
|
test('writes commit into the buffer', () {
|
||||||
final parent = Commit.lookup(repo: repo, oid: tip);
|
|
||||||
final commit = Commit.createBuffer(
|
final commit = Commit.createBuffer(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
updateRef: 'HEAD',
|
updateRef: 'HEAD',
|
||||||
|
@ -165,7 +162,7 @@ Some description.
|
||||||
author: author,
|
author: author,
|
||||||
committer: committer,
|
committer: committer,
|
||||||
tree: tree,
|
tree: tree,
|
||||||
parents: [parent],
|
parents: [Commit.lookup(repo: repo, oid: tip)],
|
||||||
);
|
);
|
||||||
|
|
||||||
const expected = """
|
const expected = """
|
||||||
|
@ -229,7 +226,7 @@ Some description.
|
||||||
expect(commit.time, 124);
|
expect(commit.time, 124);
|
||||||
expect(commit.treeOid, tree.oid);
|
expect(commit.treeOid, tree.oid);
|
||||||
expect(commit.parents.length, 2);
|
expect(commit.parents.length, 2);
|
||||||
expect(commit.parents[0], tip);
|
expect(commit.parents[0], parent1.oid);
|
||||||
expect(commit.parents[1], parent2.oid);
|
expect(commit.parents[1], parent2.oid);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -363,16 +360,16 @@ Some description.
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns nth generation ancestor commit', () {
|
test('returns nth generation ancestor commit', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: tip);
|
final ancestor = Commit.lookup(repo: repo, oid: tip).nthGenAncestor(3);
|
||||||
final ancestor = commit.nthGenAncestor(3);
|
|
||||||
|
|
||||||
expect(ancestor.oid.sha, 'f17d0d48eae3aa08cecf29128a35e310c97b3521');
|
expect(ancestor.oid.sha, 'f17d0d48eae3aa08cecf29128a35e310c97b3521');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to get nth generation ancestor and none exists',
|
test('throws when trying to get nth generation ancestor and none exists',
|
||||||
() {
|
() {
|
||||||
final commit = Commit.lookup(repo: repo, oid: tip);
|
expect(
|
||||||
expect(() => commit.nthGenAncestor(10), throwsA(isA<LibGit2Error>()));
|
() => Commit.lookup(repo: repo, oid: tip).nthGenAncestor(10),
|
||||||
|
throwsA(isA<LibGit2Error>()),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns parent at specified position', () {
|
test('returns parent at specified position', () {
|
||||||
|
@ -385,8 +382,10 @@ Some description.
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to get the parent at invalid position', () {
|
test('throws when trying to get the parent at invalid position', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: tip);
|
expect(
|
||||||
expect(() => commit.parent(10), throwsA(isA<LibGit2Error>()));
|
() => Commit.lookup(repo: repo, oid: tip).parent(10),
|
||||||
|
throwsA(isA<LibGit2Error>()),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('manually releases allocated memory', () {
|
test('manually releases allocated memory', () {
|
||||||
|
|
|
@ -27,8 +27,10 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to describe and error occurs', () {
|
test('throws when trying to describe and error occurs', () {
|
||||||
final nullRepo = Repository(nullptr);
|
expect(
|
||||||
expect(() => nullRepo.describe(), throwsA(isA<LibGit2Error>()));
|
() => Repository(nullptr).describe(),
|
||||||
|
throwsA(isA<LibGit2Error>()),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('describes commit', () {
|
test('describes commit', () {
|
||||||
|
@ -41,23 +43,28 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to describe and no reference found', () {
|
test('throws when trying to describe and no reference found', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo['f17d0d4']);
|
expect(
|
||||||
expect(() => repo.describe(commit: commit), throwsA(isA<LibGit2Error>()));
|
() => repo.describe(
|
||||||
|
commit: Commit.lookup(repo: repo, oid: repo['f17d0d4']),
|
||||||
|
),
|
||||||
|
throwsA(isA<LibGit2Error>()),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns oid when fallback argument is provided', () {
|
test('returns oid when fallback argument is provided', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo['f17d0d4']);
|
|
||||||
expect(
|
expect(
|
||||||
repo.describe(commit: commit, showCommitOidAsFallback: true),
|
repo.describe(
|
||||||
|
commit: Commit.lookup(repo: repo, oid: repo['f17d0d4']),
|
||||||
|
showCommitOidAsFallback: true,
|
||||||
|
),
|
||||||
'f17d0d4',
|
'f17d0d4',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('describes with provided strategy', () {
|
test('describes with provided strategy', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
|
||||||
expect(
|
expect(
|
||||||
repo.describe(
|
repo.describe(
|
||||||
commit: commit,
|
commit: Commit.lookup(repo: repo, oid: repo['5aecfa0']),
|
||||||
describeStrategy: GitDescribeStrategy.all,
|
describeStrategy: GitDescribeStrategy.all,
|
||||||
),
|
),
|
||||||
'heads/feature',
|
'heads/feature',
|
||||||
|
@ -70,7 +77,6 @@ void main() {
|
||||||
email: 'author@email.com',
|
email: 'author@email.com',
|
||||||
time: 1234,
|
time: 1234,
|
||||||
);
|
);
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo['fc38877']);
|
|
||||||
Tag.createAnnotated(
|
Tag.createAnnotated(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
tagName: 'test/tag1',
|
tagName: 'test/tag1',
|
||||||
|
@ -81,18 +87,20 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
repo.describe(commit: commit, pattern: 'test/*'),
|
repo.describe(
|
||||||
|
commit: Commit.lookup(repo: repo, oid: repo['fc38877']),
|
||||||
|
pattern: 'test/*',
|
||||||
|
),
|
||||||
'test/tag1-2-gfc38877',
|
'test/tag1-2-gfc38877',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('describes and follows first parent only', () {
|
test('describes and follows first parent only', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo['821ed6e']);
|
|
||||||
Tag.delete(repo: repo, name: 'v0.2');
|
Tag.delete(repo: repo, name: 'v0.2');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
repo.describe(
|
repo.describe(
|
||||||
commit: commit,
|
commit: Commit.lookup(repo: repo, oid: repo['821ed6e']),
|
||||||
onlyFollowFirstParent: true,
|
onlyFollowFirstParent: true,
|
||||||
describeStrategy: GitDescribeStrategy.tags,
|
describeStrategy: GitDescribeStrategy.tags,
|
||||||
),
|
),
|
||||||
|
|
|
@ -144,10 +144,9 @@ index e69de29..c217c63 100644
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns diff between index and tree', () {
|
test('returns diff between index and tree', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo.head.target);
|
|
||||||
final diff = Diff.treeToIndex(
|
final diff = Diff.treeToIndex(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
tree: commit.tree,
|
tree: Commit.lookup(repo: repo, oid: repo.head.target).tree,
|
||||||
index: repo.index,
|
index: repo.index,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -167,8 +166,10 @@ index e69de29..c217c63 100644
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns diff between tree and workdir', () {
|
test('returns diff between tree and workdir', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo.head.target);
|
final diff = Diff.treeToWorkdir(
|
||||||
final diff = Diff.treeToWorkdir(repo: repo, tree: commit.tree);
|
repo: repo,
|
||||||
|
tree: Commit.lookup(repo: repo, oid: repo.head.target).tree,
|
||||||
|
);
|
||||||
|
|
||||||
expect(diff.length, 9);
|
expect(diff.length, 9);
|
||||||
for (var i = 0; i < diff.deltas.length; i++) {
|
for (var i = 0; i < diff.deltas.length; i++) {
|
||||||
|
@ -185,8 +186,10 @@ index e69de29..c217c63 100644
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns diff between tree and workdir with index', () {
|
test('returns diff between tree and workdir with index', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo.head.target);
|
final diff = Diff.treeToWorkdirWithIndex(
|
||||||
final diff = Diff.treeToWorkdirWithIndex(repo: repo, tree: commit.tree);
|
repo: repo,
|
||||||
|
tree: Commit.lookup(repo: repo, oid: repo.head.target).tree,
|
||||||
|
);
|
||||||
|
|
||||||
expect(diff.length, 11);
|
expect(diff.length, 11);
|
||||||
for (var i = 0; i < diff.deltas.length; i++) {
|
for (var i = 0; i < diff.deltas.length; i++) {
|
||||||
|
@ -207,12 +210,10 @@ index e69de29..c217c63 100644
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns diff between tree and tree', () {
|
test('returns diff between tree and tree', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo.head.target);
|
|
||||||
final newTree = Tree.lookup(repo: repo, oid: repo['b85d53c']);
|
|
||||||
final diff = Diff.treeToTree(
|
final diff = Diff.treeToTree(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oldTree: commit.tree,
|
oldTree: Commit.lookup(repo: repo, oid: repo.head.target).tree,
|
||||||
newTree: newTree,
|
newTree: Tree.lookup(repo: repo, oid: repo['b85d53c']),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(diff.length, 10);
|
expect(diff.length, 10);
|
||||||
|
@ -222,10 +223,9 @@ index e69de29..c217c63 100644
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns diff between tree and empty tree', () {
|
test('returns diff between tree and empty tree', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo.head.target);
|
|
||||||
final diff = Diff.treeToTree(
|
final diff = Diff.treeToTree(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oldTree: commit.tree,
|
oldTree: Commit.lookup(repo: repo, oid: repo.head.target).tree,
|
||||||
newTree: null,
|
newTree: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -236,11 +236,10 @@ index e69de29..c217c63 100644
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns diff between empty tree and tree', () {
|
test('returns diff between empty tree and tree', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo.head.target);
|
|
||||||
final diff = Diff.treeToTree(
|
final diff = Diff.treeToTree(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oldTree: null,
|
oldTree: null,
|
||||||
newTree: commit.tree,
|
newTree: Commit.lookup(repo: repo, oid: repo.head.target).tree,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(diff.length, 11);
|
expect(diff.length, 11);
|
||||||
|
@ -295,11 +294,10 @@ index e69de29..c217c63 100644
|
||||||
|
|
||||||
test('merges diffs', () {
|
test('merges diffs', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo.head.target);
|
final commit = Commit.lookup(repo: repo, oid: repo.head.target);
|
||||||
final newTree = Tree.lookup(repo: repo, oid: repo['b85d53c']);
|
|
||||||
final diff1 = Diff.treeToTree(
|
final diff1 = Diff.treeToTree(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oldTree: commit.tree,
|
oldTree: commit.tree,
|
||||||
newTree: newTree,
|
newTree: Tree.lookup(repo: repo, oid: repo['b85d53c']),
|
||||||
);
|
);
|
||||||
final diff2 = Diff.treeToWorkdir(repo: repo, tree: commit.tree);
|
final diff2 = Diff.treeToWorkdir(repo: repo, tree: commit.tree);
|
||||||
|
|
||||||
|
@ -358,13 +356,12 @@ index e69de29..c217c63 100644
|
||||||
});
|
});
|
||||||
|
|
||||||
test('applies diff to repository', () {
|
test('applies diff to repository', () {
|
||||||
final diff = Diff.parse(patchText);
|
|
||||||
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
||||||
|
|
||||||
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
||||||
expect(file.readAsStringSync(), '');
|
expect(file.readAsStringSync(), '');
|
||||||
|
|
||||||
diff.apply(repo: repo);
|
Diff.parse(patchText).apply(repo: repo);
|
||||||
expect(file.readAsStringSync(), 'Modified content\n');
|
expect(file.readAsStringSync(), 'Modified content\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -396,78 +393,83 @@ index e69de29..c217c63 100644
|
||||||
});
|
});
|
||||||
|
|
||||||
test('does not apply hunk with non existing index', () {
|
test('does not apply hunk with non existing index', () {
|
||||||
final diff = Diff.parse(patchText);
|
|
||||||
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
||||||
|
|
||||||
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
||||||
expect(file.readAsStringSync(), '');
|
expect(file.readAsStringSync(), '');
|
||||||
|
|
||||||
diff.apply(repo: repo, hunkIndex: 10);
|
Diff.parse(patchText).apply(repo: repo, hunkIndex: 10);
|
||||||
expect(file.readAsStringSync(), '');
|
expect(file.readAsStringSync(), '');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('applies diff to tree', () {
|
test('applies diff to tree', () {
|
||||||
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
||||||
|
|
||||||
final oldBlob = Blob.lookup(
|
expect(
|
||||||
repo: repo,
|
Blob.lookup(
|
||||||
oid: repo.index['subdir/modified_file'].oid,
|
repo: repo,
|
||||||
|
oid: repo.index['subdir/modified_file'].oid,
|
||||||
|
).content,
|
||||||
|
'',
|
||||||
);
|
);
|
||||||
expect(oldBlob.content, '');
|
|
||||||
|
|
||||||
final diff = Diff.parse(patchText);
|
final newIndex = Diff.parse(patchText).applyToTree(
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo.head.target);
|
|
||||||
|
|
||||||
final newIndex = diff.applyToTree(repo: repo, tree: commit.tree);
|
|
||||||
final newBlob = Blob.lookup(
|
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oid: newIndex['subdir/modified_file'].oid,
|
tree: Commit.lookup(repo: repo, oid: repo.head.target).tree,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
Blob.lookup(
|
||||||
|
repo: repo,
|
||||||
|
oid: newIndex['subdir/modified_file'].oid,
|
||||||
|
).content,
|
||||||
|
'Modified content\n',
|
||||||
);
|
);
|
||||||
expect(newBlob.content, 'Modified content\n');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('applies hunk with provided index to tree', () {
|
test('applies hunk with provided index to tree', () {
|
||||||
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
||||||
|
|
||||||
final oldBlob = Blob.lookup(
|
expect(
|
||||||
repo: repo,
|
Blob.lookup(
|
||||||
oid: repo.index['subdir/modified_file'].oid,
|
repo: repo,
|
||||||
|
oid: repo.index['subdir/modified_file'].oid,
|
||||||
|
).content,
|
||||||
|
'',
|
||||||
);
|
);
|
||||||
expect(oldBlob.content, '');
|
|
||||||
|
|
||||||
final diff = Diff.parse(patchText);
|
final diff = Diff.parse(patchText);
|
||||||
final hunk = diff.patches.first.hunks.first;
|
final hunk = diff.patches.first.hunks.first;
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo.head.target);
|
|
||||||
|
|
||||||
final newIndex = diff.applyToTree(
|
final newIndex = diff.applyToTree(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
tree: commit.tree,
|
tree: Commit.lookup(repo: repo, oid: repo.head.target).tree,
|
||||||
hunkIndex: hunk.index,
|
hunkIndex: hunk.index,
|
||||||
);
|
);
|
||||||
final newBlob = Blob.lookup(
|
expect(
|
||||||
repo: repo,
|
Blob.lookup(
|
||||||
oid: newIndex['subdir/modified_file'].oid,
|
repo: repo,
|
||||||
|
oid: newIndex['subdir/modified_file'].oid,
|
||||||
|
).content,
|
||||||
|
'Modified content\n',
|
||||||
);
|
);
|
||||||
expect(newBlob.content, 'Modified content\n');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to apply diff to tree and error occurs', () {
|
test('throws when trying to apply diff to tree and error occurs', () {
|
||||||
final diff = Diff.parse(patchText);
|
|
||||||
expect(
|
expect(
|
||||||
() => diff.applyToTree(repo: repo, tree: Tree(nullptr)),
|
() => Diff.parse(patchText).applyToTree(
|
||||||
|
repo: repo,
|
||||||
|
tree: Tree(nullptr),
|
||||||
|
),
|
||||||
throwsA(isA<LibGit2Error>()),
|
throwsA(isA<LibGit2Error>()),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('finds similar entries', () {
|
test('finds similar entries', () {
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo.head.target);
|
|
||||||
final newTree = Tree.lookup(repo: repo, oid: repo.index.writeTree());
|
|
||||||
|
|
||||||
final diff = Diff.treeToTree(
|
final diff = Diff.treeToTree(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oldTree: commit.tree,
|
oldTree: Commit.lookup(repo: repo, oid: repo.head.target).tree,
|
||||||
newTree: newTree,
|
newTree: Tree.lookup(repo: repo, oid: repo.index.writeTree()),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
diff.deltas.singleWhere((e) => e.newFile.path == 'staged_new').status,
|
diff.deltas.singleWhere((e) => e.newFile.path == 'staged_new').status,
|
||||||
|
@ -554,13 +556,11 @@ index e69de29..c217c63 100644
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns patch diff string', () {
|
test('returns patch diff string', () {
|
||||||
final diff = Diff.parse(patchText);
|
expect(Diff.parse(patchText).patch, patchText);
|
||||||
expect(diff.patch, patchText);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns hunks in a patch', () {
|
test('returns hunks in a patch', () {
|
||||||
final diff = Diff.parse(patchText);
|
final patch = Patch.fromDiff(diff: Diff.parse(patchText), index: 0);
|
||||||
final patch = Patch.fromDiff(diff: diff, index: 0);
|
|
||||||
final hunk = patch.hunks[0];
|
final hunk = patch.hunks[0];
|
||||||
|
|
||||||
expect(patch.hunks.length, 1);
|
expect(patch.hunks.length, 1);
|
||||||
|
@ -573,8 +573,7 @@ index e69de29..c217c63 100644
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns lines in a hunk', () {
|
test('returns lines in a hunk', () {
|
||||||
final diff = Diff.parse(patchText);
|
final patch = Patch.fromDiff(diff: Diff.parse(patchText), index: 0);
|
||||||
final patch = Patch.fromDiff(diff: diff, index: 0);
|
|
||||||
final hunk = patch.hunks[0];
|
final hunk = patch.hunks[0];
|
||||||
final line = hunk.lines[0];
|
final line = hunk.lines[0];
|
||||||
|
|
||||||
|
|
|
@ -159,10 +159,9 @@ void main() {
|
||||||
|
|
||||||
group('addFromBuffer()', () {
|
group('addFromBuffer()', () {
|
||||||
test('updates index entry from a buffer', () {
|
test('updates index entry from a buffer', () {
|
||||||
final entry = index['file'];
|
|
||||||
expect(repo.status, isEmpty);
|
expect(repo.status, isEmpty);
|
||||||
|
|
||||||
index.addFromBuffer(entry: entry, buffer: 'updated');
|
index.addFromBuffer(entry: index['file'], buffer: 'updated');
|
||||||
expect(repo.status, {
|
expect(repo.status, {
|
||||||
'file': {GitStatus.indexModified, GitStatus.wtModified}
|
'file': {GitStatus.indexModified, GitStatus.wtModified}
|
||||||
});
|
});
|
||||||
|
@ -282,9 +281,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reads tree with provided SHA hex', () {
|
test('reads tree with provided SHA hex', () {
|
||||||
final tree = Tree.lookup(repo: repo, oid: repo['df2b8fc']);
|
|
||||||
expect(index.length, 4);
|
expect(index.length, 4);
|
||||||
index.readTree(tree);
|
index.readTree(Tree.lookup(repo: repo, oid: repo['df2b8fc']));
|
||||||
|
|
||||||
expect(index.length, 1);
|
expect(index.length, 1);
|
||||||
|
|
||||||
|
@ -294,8 +292,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('writes tree', () {
|
test('writes tree', () {
|
||||||
final oid = index.writeTree();
|
expect(index.writeTree().sha, 'a8ae3dd59e6e1802c6f78e05e301bfd57c9f334f');
|
||||||
expect(oid.sha, 'a8ae3dd59e6e1802c6f78e05e301bfd57c9f334f');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to write tree to invalid repository', () {
|
test('throws when trying to write tree to invalid repository', () {
|
||||||
|
@ -309,14 +306,14 @@ void main() {
|
||||||
final tmpDir = setupRepo(Directory(mergeRepoPath));
|
final tmpDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final repo = Repository.open(tmpDir.path);
|
final repo = Repository.open(tmpDir.path);
|
||||||
|
|
||||||
final conflictBranch = Branch.lookup(repo: repo, name: 'conflict-branch');
|
Merge.commit(
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oid: conflictBranch.target,
|
commit: AnnotatedCommit.lookup(
|
||||||
|
repo: repo,
|
||||||
|
oid: Branch.lookup(repo: repo, name: 'conflict-branch').target,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Merge.commit(repo: repo, commit: commit);
|
|
||||||
|
|
||||||
expect(() => repo.index.writeTree(), throwsA(isA<LibGit2Error>()));
|
expect(() => repo.index.writeTree(), throwsA(isA<LibGit2Error>()));
|
||||||
|
|
||||||
repo.free();
|
repo.free();
|
||||||
|
@ -341,19 +338,17 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = Branch.lookup(
|
|
||||||
repo: conflictRepo,
|
|
||||||
name: 'ancestor-conflict',
|
|
||||||
);
|
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: conflictRepo,
|
|
||||||
oid: conflictBranch.target,
|
|
||||||
);
|
|
||||||
|
|
||||||
Checkout.reference(repo: conflictRepo, name: 'refs/heads/feature');
|
Checkout.reference(repo: conflictRepo, name: 'refs/heads/feature');
|
||||||
conflictRepo.setHead('refs/heads/feature');
|
conflictRepo.setHead('refs/heads/feature');
|
||||||
|
|
||||||
Merge.commit(repo: conflictRepo, commit: commit);
|
Merge.commit(
|
||||||
|
repo: conflictRepo,
|
||||||
|
commit: AnnotatedCommit.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
oid: Branch.lookup(repo: conflictRepo, name: 'ancestor-conflict')
|
||||||
|
.target,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
final conflictedFile = conflictRepo.index.conflicts['feature_file']!;
|
final conflictedFile = conflictRepo.index.conflicts['feature_file']!;
|
||||||
expect(conflictedFile.ancestor?.path, 'feature_file');
|
expect(conflictedFile.ancestor?.path, 'feature_file');
|
||||||
|
@ -369,16 +364,16 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = Branch.lookup(
|
Merge.commit(
|
||||||
repo: conflictRepo,
|
repo: conflictRepo,
|
||||||
name: 'conflict-branch',
|
commit: AnnotatedCommit.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
oid: Branch.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
name: 'conflict-branch',
|
||||||
|
).target,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: conflictRepo,
|
|
||||||
oid: conflictBranch.target,
|
|
||||||
);
|
|
||||||
|
|
||||||
Merge.commit(repo: conflictRepo, commit: commit);
|
|
||||||
|
|
||||||
final conflictedFile = conflictRepo.index.conflicts['conflict_file']!;
|
final conflictedFile = conflictRepo.index.conflicts['conflict_file']!;
|
||||||
expect(conflictedFile.ancestor?.path, null);
|
expect(conflictedFile.ancestor?.path, null);
|
||||||
|
@ -394,19 +389,17 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = Branch.lookup(
|
|
||||||
repo: conflictRepo,
|
|
||||||
name: 'ancestor-conflict',
|
|
||||||
);
|
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: conflictRepo,
|
|
||||||
oid: conflictBranch.target,
|
|
||||||
);
|
|
||||||
|
|
||||||
Checkout.reference(repo: conflictRepo, name: 'refs/heads/our-conflict');
|
Checkout.reference(repo: conflictRepo, name: 'refs/heads/our-conflict');
|
||||||
conflictRepo.setHead('refs/heads/our-conflict');
|
conflictRepo.setHead('refs/heads/our-conflict');
|
||||||
|
|
||||||
Merge.commit(repo: conflictRepo, commit: commit);
|
Merge.commit(
|
||||||
|
repo: conflictRepo,
|
||||||
|
commit: AnnotatedCommit.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
oid: Branch.lookup(repo: conflictRepo, name: 'ancestor-conflict')
|
||||||
|
.target,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
final conflictedFile = conflictRepo.index.conflicts['feature_file']!;
|
final conflictedFile = conflictRepo.index.conflicts['feature_file']!;
|
||||||
expect(conflictedFile.ancestor?.path, 'feature_file');
|
expect(conflictedFile.ancestor?.path, 'feature_file');
|
||||||
|
@ -422,19 +415,16 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = Branch.lookup(
|
|
||||||
repo: conflictRepo,
|
|
||||||
name: 'their-conflict',
|
|
||||||
);
|
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: conflictRepo,
|
|
||||||
oid: conflictBranch.target,
|
|
||||||
);
|
|
||||||
|
|
||||||
Checkout.reference(repo: conflictRepo, name: 'refs/heads/feature');
|
Checkout.reference(repo: conflictRepo, name: 'refs/heads/feature');
|
||||||
conflictRepo.setHead('refs/heads/feature');
|
conflictRepo.setHead('refs/heads/feature');
|
||||||
|
|
||||||
Merge.commit(repo: conflictRepo, commit: commit);
|
Merge.commit(
|
||||||
|
repo: conflictRepo,
|
||||||
|
commit: AnnotatedCommit.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
oid: Branch.lookup(repo: conflictRepo, name: 'their-conflict').target,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
final conflictedFile = conflictRepo.index.conflicts['feature_file']!;
|
final conflictedFile = conflictRepo.index.conflicts['feature_file']!;
|
||||||
expect(conflictedFile.ancestor?.path, 'feature_file');
|
expect(conflictedFile.ancestor?.path, 'feature_file');
|
||||||
|
@ -450,17 +440,18 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = Branch.lookup(
|
|
||||||
repo: conflictRepo,
|
|
||||||
name: 'conflict-branch',
|
|
||||||
);
|
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: conflictRepo,
|
|
||||||
oid: conflictBranch.target,
|
|
||||||
);
|
|
||||||
final index = conflictRepo.index;
|
final index = conflictRepo.index;
|
||||||
|
|
||||||
Merge.commit(repo: conflictRepo, commit: commit);
|
Merge.commit(
|
||||||
|
repo: conflictRepo,
|
||||||
|
commit: AnnotatedCommit.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
oid: Branch.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
name: 'conflict-branch',
|
||||||
|
).target,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
expect(index.hasConflicts, true);
|
expect(index.hasConflicts, true);
|
||||||
expect(index['.gitignore'].isConflict, false);
|
expect(index['.gitignore'].isConflict, false);
|
||||||
|
@ -490,17 +481,18 @@ void main() {
|
||||||
final repoDir = setupRepo(Directory(mergeRepoPath));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = Branch.lookup(
|
|
||||||
repo: conflictRepo,
|
|
||||||
name: 'conflict-branch',
|
|
||||||
);
|
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: conflictRepo,
|
|
||||||
oid: conflictBranch.target,
|
|
||||||
);
|
|
||||||
final index = conflictRepo.index;
|
final index = conflictRepo.index;
|
||||||
|
|
||||||
Merge.commit(repo: conflictRepo, commit: commit);
|
Merge.commit(
|
||||||
|
repo: conflictRepo,
|
||||||
|
commit: AnnotatedCommit.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
oid: Branch.lookup(
|
||||||
|
repo: conflictRepo,
|
||||||
|
name: 'conflict-branch',
|
||||||
|
).target,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
expect(index.hasConflicts, true);
|
expect(index.hasConflicts, true);
|
||||||
expect(index.conflicts.length, 1);
|
expect(index.conflicts.length, 1);
|
||||||
|
|
|
@ -26,11 +26,13 @@ void main() {
|
||||||
group('Merge', () {
|
group('Merge', () {
|
||||||
group('analysis', () {
|
group('analysis', () {
|
||||||
test('is up to date when no reference is provided', () {
|
test('is up to date when no reference is provided', () {
|
||||||
final result = Merge.analysis(repo: repo, theirHead: repo['c68ff54']);
|
expect(
|
||||||
expect(result, [
|
Merge.analysis(repo: repo, theirHead: repo['c68ff54']),
|
||||||
{GitMergeAnalysis.upToDate},
|
[
|
||||||
GitMergePreference.none,
|
{GitMergeAnalysis.upToDate},
|
||||||
]);
|
GitMergePreference.none,
|
||||||
|
],
|
||||||
|
);
|
||||||
expect(repo.status, isEmpty);
|
expect(repo.status, isEmpty);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -45,11 +47,10 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('is fast forward', () {
|
test('is fast forward', () {
|
||||||
final ffCommit = Commit.lookup(repo: repo, oid: repo['f17d0d4']);
|
|
||||||
final ffBranch = Branch.create(
|
final ffBranch = Branch.create(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
name: 'ff-branch',
|
name: 'ff-branch',
|
||||||
target: ffCommit,
|
target: Commit.lookup(repo: repo, oid: repo['f17d0d4']),
|
||||||
);
|
);
|
||||||
|
|
||||||
final result = Merge.analysis(
|
final result = Merge.analysis(
|
||||||
|
@ -73,10 +74,6 @@ void main() {
|
||||||
|
|
||||||
test('writes conflicts to index', () {
|
test('writes conflicts to index', () {
|
||||||
final conflictBranch = Branch.lookup(repo: repo, name: 'conflict-branch');
|
final conflictBranch = Branch.lookup(repo: repo, name: 'conflict-branch');
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: repo,
|
|
||||||
oid: conflictBranch.target,
|
|
||||||
);
|
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
|
|
||||||
final result = Merge.analysis(
|
final result = Merge.analysis(
|
||||||
|
@ -85,7 +82,10 @@ void main() {
|
||||||
);
|
);
|
||||||
expect(result[0], {GitMergeAnalysis.normal});
|
expect(result[0], {GitMergeAnalysis.normal});
|
||||||
|
|
||||||
Merge.commit(repo: repo, commit: commit);
|
Merge.commit(
|
||||||
|
repo: repo,
|
||||||
|
commit: AnnotatedCommit.lookup(repo: repo, oid: conflictBranch.target),
|
||||||
|
);
|
||||||
expect(index.hasConflicts, true);
|
expect(index.hasConflicts, true);
|
||||||
expect(index.conflicts.length, 1);
|
expect(index.conflicts.length, 1);
|
||||||
expect(repo.state, GitRepositoryState.merge);
|
expect(repo.state, GitRepositoryState.merge);
|
||||||
|
@ -122,19 +122,16 @@ master conflict edit
|
||||||
conflict branch edit
|
conflict branch edit
|
||||||
>>>>>>> conflict_file
|
>>>>>>> conflict_file
|
||||||
""";
|
""";
|
||||||
final conflictBranch = Branch.lookup(
|
|
||||||
repo: repo,
|
|
||||||
name: 'conflict-branch',
|
|
||||||
);
|
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: repo,
|
|
||||||
oid: conflictBranch.target,
|
|
||||||
);
|
|
||||||
final index = repo.index;
|
|
||||||
|
|
||||||
Merge.commit(repo: repo, commit: commit);
|
Merge.commit(
|
||||||
|
repo: repo,
|
||||||
|
commit: AnnotatedCommit.lookup(
|
||||||
|
repo: repo,
|
||||||
|
oid: Branch.lookup(repo: repo, name: 'conflict-branch').target,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
final conflictedFile = index.conflicts['conflict_file']!;
|
final conflictedFile = repo.index.conflicts['conflict_file']!;
|
||||||
final diff = Merge.fileFromIndex(
|
final diff = Merge.fileFromIndex(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
ancestor: null,
|
ancestor: null,
|
||||||
|
@ -153,21 +150,19 @@ Feature edit on feature branch
|
||||||
Another feature edit
|
Another feature edit
|
||||||
>>>>>>> feature_file
|
>>>>>>> feature_file
|
||||||
""";
|
""";
|
||||||
final conflictBranch = Branch.lookup(
|
|
||||||
repo: repo,
|
|
||||||
name: 'ancestor-conflict',
|
|
||||||
);
|
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: repo,
|
|
||||||
oid: conflictBranch.target,
|
|
||||||
);
|
|
||||||
Checkout.reference(repo: repo, name: 'refs/heads/feature');
|
Checkout.reference(repo: repo, name: 'refs/heads/feature');
|
||||||
repo.setHead('refs/heads/feature');
|
repo.setHead('refs/heads/feature');
|
||||||
final index = repo.index;
|
|
||||||
|
|
||||||
Merge.commit(repo: repo, commit: commit);
|
Merge.commit(
|
||||||
|
repo: repo,
|
||||||
|
commit: AnnotatedCommit.lookup(
|
||||||
|
repo: repo,
|
||||||
|
oid: Branch.lookup(repo: repo, name: 'ancestor-conflict').target,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
final conflictedFile = index.conflicts['feature_file']!;
|
final conflictedFile = repo.index.conflicts['feature_file']!;
|
||||||
final diff = Merge.fileFromIndex(
|
final diff = Merge.fileFromIndex(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
ancestor: conflictedFile.ancestor,
|
ancestor: conflictedFile.ancestor,
|
||||||
|
@ -186,24 +181,18 @@ master conflict edit
|
||||||
conflict branch edit
|
conflict branch edit
|
||||||
>>>>>>> conflict_file
|
>>>>>>> conflict_file
|
||||||
""";
|
""";
|
||||||
final conflictBranch = Branch.lookup(
|
|
||||||
repo: repo,
|
|
||||||
name: 'conflict-branch',
|
|
||||||
);
|
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: repo,
|
|
||||||
oid: conflictBranch.target,
|
|
||||||
);
|
|
||||||
final index = repo.index;
|
|
||||||
|
|
||||||
Merge.commit(
|
Merge.commit(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
commit: commit,
|
commit: AnnotatedCommit.lookup(
|
||||||
|
repo: repo,
|
||||||
|
oid: Branch.lookup(repo: repo, name: 'conflict-branch').target,
|
||||||
|
),
|
||||||
mergeFlags: {GitMergeFlag.noRecursive},
|
mergeFlags: {GitMergeFlag.noRecursive},
|
||||||
fileFlags: {GitMergeFileFlag.ignoreWhitespaceEOL},
|
fileFlags: {GitMergeFileFlag.ignoreWhitespaceEOL},
|
||||||
);
|
);
|
||||||
|
|
||||||
final conflictedFile = index.conflicts['conflict_file']!;
|
final conflictedFile = repo.index.conflicts['conflict_file']!;
|
||||||
final diff = Merge.fileFromIndex(
|
final diff = Merge.fileFromIndex(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
ancestor: null,
|
ancestor: null,
|
||||||
|
@ -215,19 +204,16 @@ conflict branch edit
|
||||||
});
|
});
|
||||||
|
|
||||||
test('merges with provided merge favor', () {
|
test('merges with provided merge favor', () {
|
||||||
final conflictBranch = Branch.lookup(
|
Merge.commit(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
name: 'conflict-branch',
|
commit: AnnotatedCommit.lookup(
|
||||||
|
repo: repo,
|
||||||
|
oid: Branch.lookup(repo: repo, name: 'conflict-branch').target,
|
||||||
|
),
|
||||||
|
favor: GitMergeFileFavor.ours,
|
||||||
);
|
);
|
||||||
final commit = AnnotatedCommit.lookup(
|
|
||||||
repo: repo,
|
|
||||||
oid: conflictBranch.target,
|
|
||||||
);
|
|
||||||
final index = repo.index;
|
|
||||||
|
|
||||||
Merge.commit(repo: repo, commit: commit, favor: GitMergeFileFavor.ours);
|
expect(repo.index.conflicts, isEmpty);
|
||||||
|
|
||||||
expect(index.conflicts, isEmpty);
|
|
||||||
expect(
|
expect(
|
||||||
File(p.join(repo.workdir, 'conflict_file')).readAsStringSync(),
|
File(p.join(repo.workdir, 'conflict_file')).readAsStringSync(),
|
||||||
'master conflict edit\n',
|
'master conflict edit\n',
|
||||||
|
@ -305,49 +291,40 @@ theirs content
|
||||||
group('merge commits', () {
|
group('merge commits', () {
|
||||||
test('merges with default values', () {
|
test('merges with default values', () {
|
||||||
final theirCommit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
final theirCommit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
final theirCommitAnnotated = AnnotatedCommit.lookup(
|
|
||||||
repo: repo,
|
|
||||||
oid: theirCommit.oid,
|
|
||||||
);
|
|
||||||
final ourCommit = Commit.lookup(repo: repo, oid: repo['1490545']);
|
|
||||||
|
|
||||||
final mergeIndex = Merge.commits(
|
final mergeIndex = Merge.commits(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
ourCommit: ourCommit,
|
ourCommit: Commit.lookup(repo: repo, oid: repo['1490545']),
|
||||||
theirCommit: theirCommit,
|
theirCommit: theirCommit,
|
||||||
);
|
);
|
||||||
expect(mergeIndex.conflicts, isEmpty);
|
expect(mergeIndex.conflicts, isEmpty);
|
||||||
final mergeCommitsTree = mergeIndex.writeTree(repo);
|
final mergeCommitsTree = mergeIndex.writeTree(repo);
|
||||||
|
|
||||||
Merge.commit(repo: repo, commit: theirCommitAnnotated);
|
Merge.commit(
|
||||||
final index = repo.index;
|
repo: repo,
|
||||||
expect(index.conflicts, isEmpty);
|
commit: AnnotatedCommit.lookup(repo: repo, oid: theirCommit.oid),
|
||||||
final mergeTree = index.writeTree();
|
);
|
||||||
|
expect(repo.index.conflicts, isEmpty);
|
||||||
|
final mergeTree = repo.index.writeTree();
|
||||||
|
|
||||||
expect(mergeCommitsTree == mergeTree, true);
|
expect(mergeCommitsTree == mergeTree, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('merges with provided favor', () {
|
test('merges with provided favor', () {
|
||||||
final theirCommit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
|
||||||
final ourCommit = Commit.lookup(repo: repo, oid: repo['1490545']);
|
|
||||||
|
|
||||||
final mergeIndex = Merge.commits(
|
final mergeIndex = Merge.commits(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
ourCommit: ourCommit,
|
ourCommit: Commit.lookup(repo: repo, oid: repo['1490545']),
|
||||||
theirCommit: theirCommit,
|
theirCommit: Commit.lookup(repo: repo, oid: repo['5aecfa0']),
|
||||||
favor: GitMergeFileFavor.ours,
|
favor: GitMergeFileFavor.ours,
|
||||||
);
|
);
|
||||||
expect(mergeIndex.conflicts, isEmpty);
|
expect(mergeIndex.conflicts, isEmpty);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('merges with provided merge and file flags', () {
|
test('merges with provided merge and file flags', () {
|
||||||
final theirCommit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
|
||||||
final ourCommit = Commit.lookup(repo: repo, oid: repo['1490545']);
|
|
||||||
|
|
||||||
final mergeIndex = Merge.commits(
|
final mergeIndex = Merge.commits(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
ourCommit: ourCommit,
|
ourCommit: Commit.lookup(repo: repo, oid: repo['1490545']),
|
||||||
theirCommit: theirCommit,
|
theirCommit: Commit.lookup(repo: repo, oid: repo['5aecfa0']),
|
||||||
mergeFlags: {
|
mergeFlags: {
|
||||||
GitMergeFlag.findRenames,
|
GitMergeFlag.findRenames,
|
||||||
GitMergeFlag.noRecursive,
|
GitMergeFlag.noRecursive,
|
||||||
|
@ -374,31 +351,33 @@ theirs content
|
||||||
});
|
});
|
||||||
|
|
||||||
test('finds merge base for two commits', () {
|
test('finds merge base for two commits', () {
|
||||||
var base = Merge.base(
|
expect(
|
||||||
repo: repo,
|
Merge.base(repo: repo, commits: [repo['1490545'], repo['5aecfa0']]).sha,
|
||||||
commits: [repo['1490545'], repo['5aecfa0']],
|
'fc38877b2552ab554752d9a77e1f48f738cca79b',
|
||||||
);
|
);
|
||||||
expect(base.sha, 'fc38877b2552ab554752d9a77e1f48f738cca79b');
|
|
||||||
|
|
||||||
base = Merge.base(
|
expect(
|
||||||
repo: repo,
|
Merge.base(repo: repo, commits: [repo['f17d0d4'], repo['5aecfa0']]).sha,
|
||||||
commits: [repo['f17d0d4'], repo['5aecfa0']],
|
'f17d0d48eae3aa08cecf29128a35e310c97b3521',
|
||||||
);
|
);
|
||||||
expect(base.sha, 'f17d0d48eae3aa08cecf29128a35e310c97b3521');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('finds merge base for many commits', () {
|
test('finds merge base for many commits', () {
|
||||||
var base = Merge.base(
|
expect(
|
||||||
repo: repo,
|
Merge.base(
|
||||||
commits: [repo['1490545'], repo['0e409d6'], repo['5aecfa0']],
|
repo: repo,
|
||||||
|
commits: [repo['1490545'], repo['0e409d6'], repo['5aecfa0']],
|
||||||
|
).sha,
|
||||||
|
'fc38877b2552ab554752d9a77e1f48f738cca79b',
|
||||||
);
|
);
|
||||||
expect(base.sha, 'fc38877b2552ab554752d9a77e1f48f738cca79b');
|
|
||||||
|
|
||||||
base = Merge.base(
|
expect(
|
||||||
repo: repo,
|
Merge.base(
|
||||||
commits: [repo['f17d0d4'], repo['5aecfa0'], repo['0e409d6']],
|
repo: repo,
|
||||||
|
commits: [repo['f17d0d4'], repo['5aecfa0'], repo['0e409d6']],
|
||||||
|
).sha,
|
||||||
|
'f17d0d48eae3aa08cecf29128a35e310c97b3521',
|
||||||
);
|
);
|
||||||
expect(base.sha, 'f17d0d48eae3aa08cecf29128a35e310c97b3521');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to find merge base for invalid oid', () {
|
test('throws when trying to find merge base for invalid oid', () {
|
||||||
|
@ -420,11 +399,13 @@ theirs content
|
||||||
});
|
});
|
||||||
|
|
||||||
test('finds octopus merge base', () {
|
test('finds octopus merge base', () {
|
||||||
final base = Merge.octopusBase(
|
expect(
|
||||||
repo: repo,
|
Merge.octopusBase(
|
||||||
commits: [repo['1490545'], repo['0e409d6'], repo['5aecfa0']],
|
repo: repo,
|
||||||
|
commits: [repo['1490545'], repo['0e409d6'], repo['5aecfa0']],
|
||||||
|
).sha,
|
||||||
|
'fc38877b2552ab554752d9a77e1f48f738cca79b',
|
||||||
);
|
);
|
||||||
expect(base.sha, 'fc38877b2552ab554752d9a77e1f48f738cca79b');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to find octopus merge base for invalid oid', () {
|
test('throws when trying to find octopus merge base for invalid oid', () {
|
||||||
|
@ -440,10 +421,6 @@ theirs content
|
||||||
group('merge trees', () {
|
group('merge trees', () {
|
||||||
test('merges with default values', () {
|
test('merges with default values', () {
|
||||||
final theirCommit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
final theirCommit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
||||||
final theirCommitAnnotated = AnnotatedCommit.lookup(
|
|
||||||
repo: repo,
|
|
||||||
oid: theirCommit.oid,
|
|
||||||
);
|
|
||||||
final ourCommit = Commit.lookup(repo: repo, oid: repo['1490545']);
|
final ourCommit = Commit.lookup(repo: repo, oid: repo['1490545']);
|
||||||
final baseCommit = Commit.lookup(
|
final baseCommit = Commit.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
|
@ -463,11 +440,13 @@ theirs content
|
||||||
final mergeTreesTree = mergeIndex.writeTree(repo);
|
final mergeTreesTree = mergeIndex.writeTree(repo);
|
||||||
|
|
||||||
repo.setHead(ourCommit.oid);
|
repo.setHead(ourCommit.oid);
|
||||||
Merge.commit(repo: repo, commit: theirCommitAnnotated);
|
Merge.commit(
|
||||||
final index = repo.index;
|
repo: repo,
|
||||||
expect(index.conflicts, isEmpty);
|
commit: AnnotatedCommit.lookup(repo: repo, oid: theirCommit.oid),
|
||||||
final mergeTree = index.writeTree();
|
);
|
||||||
|
expect(repo.index.conflicts, isEmpty);
|
||||||
|
|
||||||
|
final mergeTree = repo.index.writeTree();
|
||||||
expect(mergeTreesTree == mergeTree, true);
|
expect(mergeTreesTree == mergeTree, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -506,19 +485,17 @@ theirs content
|
||||||
});
|
});
|
||||||
|
|
||||||
test('cherry-picks commit', () {
|
test('cherry-picks commit', () {
|
||||||
final cherry = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
Merge.cherryPick(
|
||||||
Merge.cherryPick(repo: repo, commit: cherry);
|
repo: repo,
|
||||||
|
commit: Commit.lookup(repo: repo, oid: repo['5aecfa0']),
|
||||||
|
);
|
||||||
expect(repo.state, GitRepositoryState.cherrypick);
|
expect(repo.state, GitRepositoryState.cherrypick);
|
||||||
expect(repo.message, 'add another feature file\n');
|
expect(repo.message, 'add another feature file\n');
|
||||||
final index = repo.index;
|
expect(repo.index.conflicts, isEmpty);
|
||||||
expect(index.conflicts, isEmpty);
|
|
||||||
|
|
||||||
// pretend we've done commit
|
// pretend we've done commit
|
||||||
repo.removeMessage();
|
repo.removeMessage();
|
||||||
expect(
|
expect(() => repo.message, throwsA(isA<LibGit2Error>()));
|
||||||
() => repo.message,
|
|
||||||
throwsA(isA<LibGit2Error>()),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when error occurs', () {
|
test('throws when error occurs', () {
|
||||||
|
|
|
@ -73,10 +73,12 @@ void main() {
|
||||||
note: 'New note for HEAD',
|
note: 'New note for HEAD',
|
||||||
force: true,
|
force: true,
|
||||||
);
|
);
|
||||||
final noteBlob = Blob.lookup(repo: repo, oid: noteOid);
|
|
||||||
|
|
||||||
expect(noteOid.sha, 'ffd6e2ceaf91c00ea6d29e2e897f906da720529f');
|
expect(noteOid.sha, 'ffd6e2ceaf91c00ea6d29e2e897f906da720529f');
|
||||||
expect(noteBlob.content, 'New note for HEAD');
|
expect(
|
||||||
|
Blob.lookup(repo: repo, oid: noteOid).content,
|
||||||
|
'New note for HEAD',
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to create note and error occurs', () {
|
test('throws when trying to create note and error occurs', () {
|
||||||
|
|
|
@ -45,10 +45,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reads object', () {
|
test('reads object', () {
|
||||||
final oid = repo[blobSha];
|
final object = repo.odb.read(repo[blobSha]);
|
||||||
final object = repo.odb.read(oid);
|
|
||||||
|
|
||||||
expect(object.oid, oid);
|
expect(object.oid, repo[blobSha]);
|
||||||
expect(object.type, GitObject.blob);
|
expect(object.type, GitObject.blob);
|
||||||
expect(object.data, blobContent);
|
expect(object.data, blobContent);
|
||||||
expect(object.size, 13);
|
expect(object.size, 13);
|
||||||
|
|
|
@ -73,9 +73,8 @@ void main() {
|
||||||
|
|
||||||
test('adds commit', () {
|
test('adds commit', () {
|
||||||
final packbuilder = PackBuilder(repo);
|
final packbuilder = PackBuilder(repo);
|
||||||
final oid = repo['f17d0d4'];
|
|
||||||
|
|
||||||
packbuilder.addCommit(oid);
|
packbuilder.addCommit(repo['f17d0d4']);
|
||||||
expect(packbuilder.length, 3);
|
expect(packbuilder.length, 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -90,9 +89,8 @@ void main() {
|
||||||
|
|
||||||
test('adds tree', () {
|
test('adds tree', () {
|
||||||
final packbuilder = PackBuilder(repo);
|
final packbuilder = PackBuilder(repo);
|
||||||
final oid = repo['df2b8fc'];
|
|
||||||
|
|
||||||
packbuilder.addTree(oid);
|
packbuilder.addTree(repo['df2b8fc']);
|
||||||
expect(packbuilder.length, 2);
|
expect(packbuilder.length, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -106,11 +104,10 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('adds objects with walker', () {
|
test('adds objects with walker', () {
|
||||||
final oid = repo['f17d0d4'];
|
|
||||||
final packbuilder = PackBuilder(repo);
|
final packbuilder = PackBuilder(repo);
|
||||||
final walker = RevWalk(repo);
|
final walker = RevWalk(repo);
|
||||||
walker.sorting({GitSort.none});
|
walker.sorting({GitSort.none});
|
||||||
walker.push(oid);
|
walker.push(repo['f17d0d4']);
|
||||||
|
|
||||||
packbuilder.addWalk(walker);
|
packbuilder.addWalk(walker);
|
||||||
expect(packbuilder.length, 3);
|
expect(packbuilder.length, 3);
|
||||||
|
@ -134,20 +131,16 @@ void main() {
|
||||||
test('packs with default arguments', () {
|
test('packs with default arguments', () {
|
||||||
final objectsCount = repo.odb.objects.length;
|
final objectsCount = repo.odb.objects.length;
|
||||||
Directory(packDirPath).createSync();
|
Directory(packDirPath).createSync();
|
||||||
|
expect(repo.pack(), objectsCount);
|
||||||
final writtenCount = repo.pack();
|
|
||||||
|
|
||||||
expect(writtenCount, objectsCount);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('packs into provided path with threads set', () {
|
test('packs into provided path with threads set', () {
|
||||||
final objectsCount = repo.odb.objects.length;
|
|
||||||
final testPackPath = p.join(repo.workdir, 'test-pack');
|
final testPackPath = p.join(repo.workdir, 'test-pack');
|
||||||
Directory(testPackPath).createSync();
|
Directory(testPackPath).createSync();
|
||||||
|
|
||||||
final writtenCount = repo.pack(path: testPackPath, threads: 1);
|
final writtenCount = repo.pack(path: testPackPath, threads: 1);
|
||||||
|
|
||||||
expect(writtenCount, objectsCount);
|
expect(writtenCount, repo.odb.objects.length);
|
||||||
expect(Directory(testPackPath).listSync().isNotEmpty, true);
|
expect(Directory(testPackPath).listSync().isNotEmpty, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -167,8 +160,7 @@ void main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final writtenCount = repo.pack(packDelegate: packDelegate);
|
expect(repo.pack(packDelegate: packDelegate), 18);
|
||||||
expect(writtenCount, 18);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to write pack into invalid path', () {
|
test('throws when trying to write pack into invalid path', () {
|
||||||
|
|
|
@ -90,11 +90,9 @@ index e69de29..0000000
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates from blobs', () {
|
test('creates from blobs', () {
|
||||||
final oldBlob = Blob.lookup(repo: repo, oid: oldBlobOid);
|
|
||||||
final newBlob = Blob.lookup(repo: repo, oid: newBlobOid);
|
|
||||||
final patch = Patch.fromBlobs(
|
final patch = Patch.fromBlobs(
|
||||||
oldBlob: oldBlob,
|
oldBlob: Blob.lookup(repo: repo, oid: oldBlobOid),
|
||||||
newBlob: newBlob,
|
newBlob: Blob.lookup(repo: repo, oid: newBlobOid),
|
||||||
oldBlobPath: path,
|
oldBlobPath: path,
|
||||||
newBlobPath: path,
|
newBlobPath: path,
|
||||||
);
|
);
|
||||||
|
@ -103,10 +101,9 @@ index e69de29..0000000
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates from one blob (add)', () {
|
test('creates from one blob (add)', () {
|
||||||
final newBlob = Blob.lookup(repo: repo, oid: newBlobOid);
|
|
||||||
final patch = Patch.fromBlobs(
|
final patch = Patch.fromBlobs(
|
||||||
oldBlob: null,
|
oldBlob: null,
|
||||||
newBlob: newBlob,
|
newBlob: Blob.lookup(repo: repo, oid: newBlobOid),
|
||||||
oldBlobPath: path,
|
oldBlobPath: path,
|
||||||
newBlobPath: path,
|
newBlobPath: path,
|
||||||
);
|
);
|
||||||
|
@ -115,9 +112,8 @@ index e69de29..0000000
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates from one blob (delete)', () {
|
test('creates from one blob (delete)', () {
|
||||||
final oldBlob = Blob.lookup(repo: repo, oid: oldBlobOid);
|
|
||||||
final patch = Patch.fromBlobs(
|
final patch = Patch.fromBlobs(
|
||||||
oldBlob: oldBlob,
|
oldBlob: Blob.lookup(repo: repo, oid: oldBlobOid),
|
||||||
newBlob: null,
|
newBlob: null,
|
||||||
oldBlobPath: path,
|
oldBlobPath: path,
|
||||||
newBlobPath: path,
|
newBlobPath: path,
|
||||||
|
@ -127,9 +123,8 @@ index e69de29..0000000
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates from blob and buffer', () {
|
test('creates from blob and buffer', () {
|
||||||
final blob = Blob.lookup(repo: repo, oid: oldBlobOid);
|
|
||||||
final patch = Patch.fromBlobAndBuffer(
|
final patch = Patch.fromBlobAndBuffer(
|
||||||
blob: blob,
|
blob: Blob.lookup(repo: repo, oid: oldBlobOid),
|
||||||
buffer: newBuffer,
|
buffer: newBuffer,
|
||||||
blobPath: path,
|
blobPath: path,
|
||||||
bufferPath: path,
|
bufferPath: path,
|
||||||
|
|
|
@ -33,15 +33,7 @@ void main() {
|
||||||
time: 1234,
|
time: 1234,
|
||||||
);
|
);
|
||||||
final master = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
final master = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||||
final branchHead = AnnotatedCommit.fromReference(
|
|
||||||
repo: repo,
|
|
||||||
reference: master,
|
|
||||||
);
|
|
||||||
final feature = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
final feature = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
||||||
final ontoHead = AnnotatedCommit.fromReference(
|
|
||||||
repo: repo,
|
|
||||||
reference: feature,
|
|
||||||
);
|
|
||||||
|
|
||||||
Checkout.reference(repo: repo, name: feature.name);
|
Checkout.reference(repo: repo, name: feature.name);
|
||||||
repo.setHead(feature.name);
|
repo.setHead(feature.name);
|
||||||
|
@ -49,8 +41,8 @@ void main() {
|
||||||
|
|
||||||
final rebase = Rebase.init(
|
final rebase = Rebase.init(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
branch: branchHead,
|
branch: AnnotatedCommit.fromReference(repo: repo, reference: master),
|
||||||
onto: ontoHead,
|
onto: AnnotatedCommit.fromReference(repo: repo, reference: feature),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(rebase.origHeadOid, master.target);
|
expect(rebase.origHeadOid, master.target);
|
||||||
|
@ -85,11 +77,10 @@ void main() {
|
||||||
time: 1234,
|
time: 1234,
|
||||||
);
|
);
|
||||||
final feature = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
final feature = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
||||||
final ontoHead = AnnotatedCommit.lookup(repo: repo, oid: feature.target);
|
|
||||||
|
|
||||||
final rebase = Rebase.init(
|
final rebase = Rebase.init(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
onto: ontoHead,
|
onto: AnnotatedCommit.lookup(repo: repo, oid: feature.target),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
|
@ -126,9 +117,7 @@ void main() {
|
||||||
time: 1234,
|
time: 1234,
|
||||||
);
|
);
|
||||||
final master = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
final master = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||||
final branchHead = AnnotatedCommit.lookup(repo: repo, oid: master.target);
|
|
||||||
final feature = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
final feature = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
||||||
final upstream = AnnotatedCommit.lookup(repo: repo, oid: repo[shas[1]]);
|
|
||||||
|
|
||||||
Checkout.reference(repo: repo, name: feature.name);
|
Checkout.reference(repo: repo, name: feature.name);
|
||||||
repo.setHead(feature.name);
|
repo.setHead(feature.name);
|
||||||
|
@ -136,8 +125,8 @@ void main() {
|
||||||
|
|
||||||
final rebase = Rebase.init(
|
final rebase = Rebase.init(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
branch: branchHead,
|
branch: AnnotatedCommit.lookup(repo: repo, oid: master.target),
|
||||||
upstream: upstream,
|
upstream: AnnotatedCommit.lookup(repo: repo, oid: repo[shas[1]]),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(rebase.origHeadOid, master.target);
|
expect(rebase.origHeadOid, master.target);
|
||||||
|
@ -172,21 +161,21 @@ void main() {
|
||||||
email: 'author@email.com',
|
email: 'author@email.com',
|
||||||
time: 1234,
|
time: 1234,
|
||||||
);
|
);
|
||||||
final master = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
|
||||||
final branchHead = AnnotatedCommit.lookup(repo: repo, oid: master.target);
|
|
||||||
final conflict = Reference.lookup(
|
final conflict = Reference.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
name: 'refs/heads/conflict-branch',
|
name: 'refs/heads/conflict-branch',
|
||||||
);
|
);
|
||||||
final ontoHead = AnnotatedCommit.lookup(repo: repo, oid: conflict.target);
|
|
||||||
|
|
||||||
Checkout.reference(repo: repo, name: conflict.name);
|
Checkout.reference(repo: repo, name: conflict.name);
|
||||||
repo.setHead(conflict.name);
|
repo.setHead(conflict.name);
|
||||||
|
|
||||||
final rebase = Rebase.init(
|
final rebase = Rebase.init(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
branch: branchHead,
|
branch: AnnotatedCommit.lookup(
|
||||||
onto: ontoHead,
|
repo: repo,
|
||||||
|
oid: Reference.lookup(repo: repo, name: 'refs/heads/master').target,
|
||||||
|
),
|
||||||
|
onto: AnnotatedCommit.lookup(repo: repo, oid: conflict.target),
|
||||||
);
|
);
|
||||||
expect(rebase.operations.length, 1);
|
expect(rebase.operations.length, 1);
|
||||||
|
|
||||||
|
@ -201,21 +190,21 @@ void main() {
|
||||||
|
|
||||||
test('throws when trying to perfrom next rebase operation and error occurs',
|
test('throws when trying to perfrom next rebase operation and error occurs',
|
||||||
() {
|
() {
|
||||||
final master = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
|
||||||
final branchHead = AnnotatedCommit.lookup(repo: repo, oid: master.target);
|
|
||||||
final conflict = Reference.lookup(
|
final conflict = Reference.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
name: 'refs/heads/conflict-branch',
|
name: 'refs/heads/conflict-branch',
|
||||||
);
|
);
|
||||||
final ontoHead = AnnotatedCommit.lookup(repo: repo, oid: conflict.target);
|
|
||||||
|
|
||||||
Checkout.reference(repo: repo, name: conflict.name);
|
Checkout.reference(repo: repo, name: conflict.name);
|
||||||
repo.setHead(conflict.name);
|
repo.setHead(conflict.name);
|
||||||
|
|
||||||
final rebase = Rebase.init(
|
final rebase = Rebase.init(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
branch: branchHead,
|
branch: AnnotatedCommit.lookup(
|
||||||
onto: ontoHead,
|
repo: repo,
|
||||||
|
oid: Reference.lookup(repo: repo, name: 'refs/heads/master').target,
|
||||||
|
),
|
||||||
|
onto: AnnotatedCommit.lookup(repo: repo, oid: conflict.target),
|
||||||
);
|
);
|
||||||
expect(rebase.operations.length, 1);
|
expect(rebase.operations.length, 1);
|
||||||
|
|
||||||
|
@ -224,21 +213,21 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('aborts rebase in progress', () {
|
test('aborts rebase in progress', () {
|
||||||
final master = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
|
||||||
final branchHead = AnnotatedCommit.lookup(repo: repo, oid: master.target);
|
|
||||||
final conflict = Reference.lookup(
|
final conflict = Reference.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
name: 'refs/heads/conflict-branch',
|
name: 'refs/heads/conflict-branch',
|
||||||
);
|
);
|
||||||
final ontoHead = AnnotatedCommit.lookup(repo: repo, oid: conflict.target);
|
|
||||||
|
|
||||||
Checkout.reference(repo: repo, name: conflict.name);
|
Checkout.reference(repo: repo, name: conflict.name);
|
||||||
repo.setHead(conflict.name);
|
repo.setHead(conflict.name);
|
||||||
|
|
||||||
final rebase = Rebase.init(
|
final rebase = Rebase.init(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
branch: branchHead,
|
branch: AnnotatedCommit.lookup(
|
||||||
onto: ontoHead,
|
repo: repo,
|
||||||
|
oid: Reference.lookup(repo: repo, name: 'refs/heads/master').target,
|
||||||
|
),
|
||||||
|
onto: AnnotatedCommit.lookup(repo: repo, oid: conflict.target),
|
||||||
);
|
);
|
||||||
expect(rebase.operations.length, 1);
|
expect(rebase.operations.length, 1);
|
||||||
|
|
||||||
|
@ -252,12 +241,12 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('opens an existing rebase', () {
|
test('opens an existing rebase', () {
|
||||||
final feature = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
|
||||||
final ontoHead = AnnotatedCommit.lookup(repo: repo, oid: feature.target);
|
|
||||||
|
|
||||||
final rebase = Rebase.init(
|
final rebase = Rebase.init(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
onto: ontoHead,
|
onto: AnnotatedCommit.lookup(
|
||||||
|
repo: repo,
|
||||||
|
oid: Reference.lookup(repo: repo, name: 'refs/heads/feature').target,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
expect(rebase.operations.length, 3);
|
expect(rebase.operations.length, 3);
|
||||||
|
|
||||||
|
@ -270,11 +259,12 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('manually releases allocated memory', () {
|
test('manually releases allocated memory', () {
|
||||||
final feature = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
|
||||||
final ontoHead = AnnotatedCommit.lookup(repo: repo, oid: feature.target);
|
|
||||||
final rebase = Rebase.init(
|
final rebase = Rebase.init(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
onto: ontoHead,
|
onto: AnnotatedCommit.lookup(
|
||||||
|
repo: repo,
|
||||||
|
oid: Reference.lookup(repo: repo, name: 'refs/heads/feature').target,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(() => rebase.free(), returnsNormally);
|
expect(() => rebase.free(), returnsNormally);
|
||||||
|
|
|
@ -47,9 +47,10 @@ void main() {
|
||||||
|
|
||||||
test('returns correct type of reference', () {
|
test('returns correct type of reference', () {
|
||||||
expect(repo.head.type, ReferenceType.direct);
|
expect(repo.head.type, ReferenceType.direct);
|
||||||
|
expect(
|
||||||
final ref = Reference.lookup(repo: repo, name: 'HEAD');
|
Reference.lookup(repo: repo, name: 'HEAD').type,
|
||||||
expect(ref.type, ReferenceType.symbolic);
|
ReferenceType.symbolic,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns SHA hex of direct reference', () {
|
test('returns SHA hex of direct reference', () {
|
||||||
|
@ -57,8 +58,10 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns SHA hex of symbolic reference', () {
|
test('returns SHA hex of symbolic reference', () {
|
||||||
final ref = Reference.lookup(repo: repo, name: 'HEAD');
|
expect(
|
||||||
expect(ref.target.sha, lastCommit);
|
Reference.lookup(repo: repo, name: 'HEAD').target.sha,
|
||||||
|
lastCommit,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to resolve invalid reference', () {
|
test('throws when trying to resolve invalid reference', () {
|
||||||
|
@ -84,13 +87,17 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checks if reference is a local branch', () {
|
test('checks if reference is a local branch', () {
|
||||||
final ref = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
expect(
|
||||||
expect(ref.isBranch, true);
|
Reference.lookup(repo: repo, name: 'refs/heads/feature').isBranch,
|
||||||
|
true,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checks if reference is a note', () {
|
test('checks if reference is a note', () {
|
||||||
final ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
expect(
|
||||||
expect(ref.isNote, false);
|
Reference.lookup(repo: repo, name: 'refs/heads/master').isNote,
|
||||||
|
false,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checks if reference is a remote branch', () {
|
test('checks if reference is a remote branch', () {
|
||||||
|
@ -102,16 +109,22 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checks if reference is a tag', () {
|
test('checks if reference is a tag', () {
|
||||||
final ref = Reference.lookup(repo: repo, name: 'refs/tags/v0.1');
|
expect(
|
||||||
expect(ref.isTag, true);
|
Reference.lookup(repo: repo, name: 'refs/tags/v0.1').isTag,
|
||||||
|
true,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checks if reflog exists for the reference', () {
|
test('checks if reflog exists for the reference', () {
|
||||||
var ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
expect(
|
||||||
expect(ref.hasLog, true);
|
Reference.lookup(repo: repo, name: 'refs/heads/master').hasLog,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
ref = Reference.lookup(repo: repo, name: 'refs/tags/v0.1');
|
expect(
|
||||||
expect(ref.hasLog, false);
|
Reference.lookup(repo: repo, name: 'refs/tags/v0.1').hasLog,
|
||||||
|
false,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('ensures updates to the reference will append to its log', () {
|
test('ensures updates to the reference will append to its log', () {
|
||||||
|
@ -148,12 +161,10 @@ void main() {
|
||||||
|
|
||||||
group('create direct', () {
|
group('create direct', () {
|
||||||
test('creates with oid as target', () {
|
test('creates with oid as target', () {
|
||||||
final ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
|
||||||
|
|
||||||
Reference.create(
|
Reference.create(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
name: 'refs/tags/from.oid',
|
name: 'refs/tags/from.oid',
|
||||||
target: ref.target,
|
target: repo.head.target,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(repo.references, contains('refs/tags/from.oid'));
|
expect(repo.references, contains('refs/tags/from.oid'));
|
||||||
|
@ -319,7 +330,6 @@ void main() {
|
||||||
|
|
||||||
test('deletes reference', () {
|
test('deletes reference', () {
|
||||||
expect(repo.references, contains('refs/tags/v0.1'));
|
expect(repo.references, contains('refs/tags/v0.1'));
|
||||||
|
|
||||||
Reference.delete(repo: repo, name: 'refs/tags/v0.1');
|
Reference.delete(repo: repo, name: 'refs/tags/v0.1');
|
||||||
expect(repo.references, isNot(contains('refs/tags/v0.1')));
|
expect(repo.references, isNot(contains('refs/tags/v0.1')));
|
||||||
});
|
});
|
||||||
|
@ -470,15 +480,13 @@ void main() {
|
||||||
|
|
||||||
test('peels to object of provided type', () {
|
test('peels to object of provided type', () {
|
||||||
final ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
final ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||||
final blob = Blob.lookup(repo: repo, oid: repo['9c78c21']);
|
|
||||||
final blobRef = Reference.create(
|
final blobRef = Reference.create(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
name: 'refs/tags/blob',
|
name: 'refs/tags/blob',
|
||||||
target: blob.oid,
|
target: Blob.lookup(repo: repo, oid: repo['9c78c21']).oid,
|
||||||
);
|
);
|
||||||
final tagRef = Reference.lookup(repo: repo, name: 'refs/tags/v0.2');
|
final tagRef = Reference.lookup(repo: repo, name: 'refs/tags/v0.2');
|
||||||
final commit = Commit.lookup(repo: repo, oid: ref.target);
|
final commit = Commit.lookup(repo: repo, oid: ref.target);
|
||||||
final tree = commit.tree;
|
|
||||||
|
|
||||||
final peeledCommit = ref.peel(GitObject.commit) as Commit;
|
final peeledCommit = ref.peel(GitObject.commit) as Commit;
|
||||||
final peeledTree = ref.peel(GitObject.tree) as Tree;
|
final peeledTree = ref.peel(GitObject.tree) as Tree;
|
||||||
|
@ -486,7 +494,7 @@ void main() {
|
||||||
final peeledTag = tagRef.peel(GitObject.tag) as Tag;
|
final peeledTag = tagRef.peel(GitObject.tag) as Tag;
|
||||||
|
|
||||||
expect(peeledCommit.oid, commit.oid);
|
expect(peeledCommit.oid, commit.oid);
|
||||||
expect(peeledTree.oid, tree.oid);
|
expect(peeledTree.oid, commit.tree.oid);
|
||||||
expect(peeledBlob.content, 'Feature edit\n');
|
expect(peeledBlob.content, 'Feature edit\n');
|
||||||
expect(peeledTag.name, 'v0.2');
|
expect(peeledTag.name, 'v0.2');
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,7 +40,6 @@ void main() {
|
||||||
group('Remote', () {
|
group('Remote', () {
|
||||||
test('fetch() does not prune branch by default', () {
|
test('fetch() does not prune branch by default', () {
|
||||||
remote.fetch();
|
remote.fetch();
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
clonedRepo.branches.any((branch) => branch.name == 'origin/feature'),
|
clonedRepo.branches.any((branch) => branch.name == 'origin/feature'),
|
||||||
true,
|
true,
|
||||||
|
@ -49,7 +48,6 @@ void main() {
|
||||||
|
|
||||||
test('fetch() prunes branch with provided flag', () {
|
test('fetch() prunes branch with provided flag', () {
|
||||||
remote.fetch(prune: GitFetchPrune.prune);
|
remote.fetch(prune: GitFetchPrune.prune);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
clonedRepo.branches.any((branch) => branch.name == 'origin/feature'),
|
clonedRepo.branches.any((branch) => branch.name == 'origin/feature'),
|
||||||
false,
|
false,
|
||||||
|
@ -58,7 +56,6 @@ void main() {
|
||||||
|
|
||||||
test('fetch() does not prune branch with provided flag', () {
|
test('fetch() does not prune branch with provided flag', () {
|
||||||
remote.fetch(prune: GitFetchPrune.noPrune);
|
remote.fetch(prune: GitFetchPrune.noPrune);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
clonedRepo.branches.any((branch) => branch.name == 'origin/feature'),
|
clonedRepo.branches.any((branch) => branch.name == 'origin/feature'),
|
||||||
true,
|
true,
|
||||||
|
|
|
@ -75,12 +75,7 @@ void main() {
|
||||||
test('throws when trying to create with fetchspec with invalid remote name',
|
test('throws when trying to create with fetchspec with invalid remote name',
|
||||||
() {
|
() {
|
||||||
expect(
|
expect(
|
||||||
() => Remote.create(
|
() => Remote.create(repo: repo, name: '', url: '', fetch: ''),
|
||||||
repo: repo,
|
|
||||||
name: '',
|
|
||||||
url: '',
|
|
||||||
fetch: '',
|
|
||||||
),
|
|
||||||
throwsA(isA<LibGit2Error>()),
|
throwsA(isA<LibGit2Error>()),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -110,13 +105,13 @@ void main() {
|
||||||
final problems = Remote.rename(
|
final problems = Remote.rename(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
oldName: remoteName,
|
oldName: remoteName,
|
||||||
newName: 'new',
|
newName: 'renamed',
|
||||||
);
|
);
|
||||||
expect(problems, isEmpty);
|
expect(problems, isEmpty);
|
||||||
expect(remote.name, isNot('new'));
|
expect(remote.name, isNot('renamed'));
|
||||||
|
|
||||||
final newRemote = Remote.lookup(repo: repo, name: 'new');
|
final renamedRemote = Remote.lookup(repo: repo, name: 'renamed');
|
||||||
expect(newRemote.name, 'new');
|
expect(renamedRemote.name, 'renamed');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns list of non-default refspecs that cannot be renamed', () {
|
test('returns list of non-default refspecs that cannot be renamed', () {
|
||||||
|
@ -141,14 +136,12 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sets url', () {
|
test('sets url', () {
|
||||||
final remote = Remote.lookup(repo: repo, name: remoteName);
|
expect(Remote.lookup(repo: repo, name: remoteName).url, remoteUrl);
|
||||||
expect(remote.url, remoteUrl);
|
|
||||||
|
|
||||||
const newUrl = 'git://new/url.git';
|
const newUrl = 'git://new/url.git';
|
||||||
Remote.setUrl(repo: repo, remote: remoteName, url: newUrl);
|
Remote.setUrl(repo: repo, remote: remoteName, url: newUrl);
|
||||||
|
|
||||||
final newRemote = Remote.lookup(repo: repo, name: remoteName);
|
expect(Remote.lookup(repo: repo, name: remoteName).url, newUrl);
|
||||||
expect(newRemote.url, newUrl);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to set invalid url name', () {
|
test('throws when trying to set invalid url name', () {
|
||||||
|
@ -162,8 +155,7 @@ void main() {
|
||||||
const newUrl = 'git://new/url.git';
|
const newUrl = 'git://new/url.git';
|
||||||
Remote.setPushUrl(repo: repo, remote: remoteName, url: newUrl);
|
Remote.setPushUrl(repo: repo, remote: remoteName, url: newUrl);
|
||||||
|
|
||||||
final remote = Remote.lookup(repo: repo, name: remoteName);
|
expect(Remote.lookup(repo: repo, name: remoteName).pushUrl, newUrl);
|
||||||
expect(remote.pushUrl, newUrl);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to set invalid push url name', () {
|
test('throws when trying to set invalid push url name', () {
|
||||||
|
@ -201,8 +193,7 @@ void main() {
|
||||||
|
|
||||||
test('throws when trying to transform refspec with invalid reference name',
|
test('throws when trying to transform refspec with invalid reference name',
|
||||||
() {
|
() {
|
||||||
final remote = Remote.lookup(repo: repo, name: 'origin');
|
final refspec = Remote.lookup(repo: repo, name: 'origin').getRefspec(0);
|
||||||
final refspec = remote.getRefspec(0);
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
() => refspec.transform('invalid/name'),
|
() => refspec.transform('invalid/name'),
|
||||||
|
@ -404,9 +395,8 @@ void main() {
|
||||||
|
|
||||||
TransferProgress? callbackStats;
|
TransferProgress? callbackStats;
|
||||||
void tp(TransferProgress stats) => callbackStats = stats;
|
void tp(TransferProgress stats) => callbackStats = stats;
|
||||||
final callbacks = Callbacks(transferProgress: tp);
|
|
||||||
|
|
||||||
final stats = remote.fetch(callbacks: callbacks);
|
final stats = remote.fetch(callbacks: Callbacks(transferProgress: tp));
|
||||||
|
|
||||||
expect(stats.totalObjects == callbackStats?.totalObjects, true);
|
expect(stats.totalObjects == callbackStats?.totalObjects, true);
|
||||||
expect(stats.indexedObjects == callbackStats?.indexedObjects, true);
|
expect(stats.indexedObjects == callbackStats?.indexedObjects, true);
|
||||||
|
@ -435,13 +425,9 @@ Total 69 (delta 0), reused 1 (delta 0), pack-reused 68
|
||||||
final remote = Remote.lookup(repo: repo, name: 'libgit2');
|
final remote = Remote.lookup(repo: repo, name: 'libgit2');
|
||||||
|
|
||||||
final sidebandOutput = StringBuffer();
|
final sidebandOutput = StringBuffer();
|
||||||
void sideband(String message) {
|
void sideband(String message) => sidebandOutput.write(message);
|
||||||
sidebandOutput.write(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
final callbacks = Callbacks(sidebandProgress: sideband);
|
remote.fetch(callbacks: Callbacks(sidebandProgress: sideband));
|
||||||
|
|
||||||
remote.fetch(callbacks: callbacks);
|
|
||||||
expect(sidebandOutput.toString(), sidebandMessage);
|
expect(sidebandOutput.toString(), sidebandMessage);
|
||||||
},
|
},
|
||||||
tags: 'remote_fetch',
|
tags: 'remote_fetch',
|
||||||
|
@ -483,9 +469,7 @@ Total 69 (delta 0), reused 1 (delta 0), pack-reused 68
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
final callbacks = Callbacks(updateTips: updateTips);
|
remote.fetch(callbacks: Callbacks(updateTips: updateTips));
|
||||||
|
|
||||||
remote.fetch(callbacks: callbacks);
|
|
||||||
expect(updateTipsOutput, tipsExpected);
|
expect(updateTipsOutput, tipsExpected);
|
||||||
},
|
},
|
||||||
tags: 'remote_fetch',
|
tags: 'remote_fetch',
|
||||||
|
@ -513,9 +497,10 @@ Total 69 (delta 0), reused 1 (delta 0), pack-reused 68
|
||||||
updateRefOutput[refname] = message;
|
updateRefOutput[refname] = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
final callbacks = Callbacks(pushUpdateReference: updateRef);
|
remote.push(
|
||||||
|
refspecs: ['refs/heads/master'],
|
||||||
remote.push(refspecs: ['refs/heads/master'], callbacks: callbacks);
|
callbacks: Callbacks(pushUpdateReference: updateRef),
|
||||||
|
);
|
||||||
expect(
|
expect(
|
||||||
Commit.lookup(repo: originRepo, oid: originRepo.head.target).oid.sha,
|
Commit.lookup(repo: originRepo, oid: originRepo.head.target).oid.sha,
|
||||||
'821ed6e80627b8769d170a293862f9fc60825226',
|
'821ed6e80627b8769d170a293862f9fc60825226',
|
||||||
|
|
|
@ -171,8 +171,10 @@ void main() {
|
||||||
|
|
||||||
test('cleans up state', () {
|
test('cleans up state', () {
|
||||||
expect(repo.state, GitRepositoryState.none);
|
expect(repo.state, GitRepositoryState.none);
|
||||||
final commit = Commit.lookup(repo: repo, oid: repo['5aecfa0']);
|
Merge.cherryPick(
|
||||||
Merge.cherryPick(repo: repo, commit: commit);
|
repo: repo,
|
||||||
|
commit: Commit.lookup(repo: repo, oid: repo['5aecfa0']),
|
||||||
|
);
|
||||||
|
|
||||||
expect(repo.state, GitRepositoryState.cherrypick);
|
expect(repo.state, GitRepositoryState.cherrypick);
|
||||||
repo.stateCleanup();
|
repo.stateCleanup();
|
||||||
|
|
|
@ -25,33 +25,27 @@ void main() {
|
||||||
|
|
||||||
group('Reset', () {
|
group('Reset', () {
|
||||||
test('resets with hard', () {
|
test('resets with hard', () {
|
||||||
var contents = file.readAsStringSync();
|
expect(file.readAsStringSync(), 'Feature edit\n');
|
||||||
expect(contents, 'Feature edit\n');
|
|
||||||
|
|
||||||
repo.reset(oid: repo[sha], resetType: GitReset.hard);
|
repo.reset(oid: repo[sha], resetType: GitReset.hard);
|
||||||
contents = file.readAsStringSync();
|
expect(file.readAsStringSync(), isEmpty);
|
||||||
expect(contents, isEmpty);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('resets with soft', () {
|
test('resets with soft', () {
|
||||||
var contents = file.readAsStringSync();
|
expect(file.readAsStringSync(), 'Feature edit\n');
|
||||||
expect(contents, 'Feature edit\n');
|
|
||||||
|
|
||||||
repo.reset(oid: repo[sha], resetType: GitReset.soft);
|
repo.reset(oid: repo[sha], resetType: GitReset.soft);
|
||||||
contents = file.readAsStringSync();
|
expect(file.readAsStringSync(), 'Feature edit\n');
|
||||||
expect(contents, 'Feature edit\n');
|
|
||||||
|
|
||||||
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
||||||
expect(diff.deltas, isEmpty);
|
expect(diff.deltas, isEmpty);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('resets with mixed', () {
|
test('resets with mixed', () {
|
||||||
var contents = file.readAsStringSync();
|
expect(file.readAsStringSync(), 'Feature edit\n');
|
||||||
expect(contents, 'Feature edit\n');
|
|
||||||
|
|
||||||
repo.reset(oid: repo[sha], resetType: GitReset.mixed);
|
repo.reset(oid: repo[sha], resetType: GitReset.mixed);
|
||||||
contents = file.readAsStringSync();
|
expect(file.readAsStringSync(), 'Feature edit\n');
|
||||||
expect(contents, 'Feature edit\n');
|
|
||||||
|
|
||||||
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
||||||
expect(diff.deltas.length, 1);
|
expect(diff.deltas.length, 1);
|
||||||
|
|
|
@ -42,9 +42,8 @@ void main() {
|
||||||
|
|
||||||
test('returns list of commits with default sorting', () {
|
test('returns list of commits with default sorting', () {
|
||||||
final walker = RevWalk(repo);
|
final walker = RevWalk(repo);
|
||||||
final start = Oid.fromSHA(repo: repo, sha: log.first);
|
|
||||||
|
|
||||||
walker.push(start);
|
walker.push(repo[log.first]);
|
||||||
final commits = walker.walk();
|
final commits = walker.walk();
|
||||||
|
|
||||||
for (var i = 0; i < commits.length; i++) {
|
for (var i = 0; i < commits.length; i++) {
|
||||||
|
@ -54,9 +53,8 @@ void main() {
|
||||||
|
|
||||||
test('returns list of commits with reverse sorting', () {
|
test('returns list of commits with reverse sorting', () {
|
||||||
final walker = RevWalk(repo);
|
final walker = RevWalk(repo);
|
||||||
final start = Oid.fromSHA(repo: repo, sha: log.first);
|
|
||||||
|
|
||||||
walker.push(start);
|
walker.push(repo[log.first]);
|
||||||
walker.sorting({GitSort.reverse});
|
walker.sorting({GitSort.reverse});
|
||||||
final commits = walker.walk();
|
final commits = walker.walk();
|
||||||
|
|
||||||
|
@ -67,9 +65,8 @@ void main() {
|
||||||
|
|
||||||
test('changes sorting', () {
|
test('changes sorting', () {
|
||||||
final walker = RevWalk(repo);
|
final walker = RevWalk(repo);
|
||||||
final start = Oid.fromSHA(repo: repo, sha: log.first);
|
|
||||||
|
|
||||||
walker.push(start);
|
walker.push(repo[log.first]);
|
||||||
final timeSortedCommits = walker.walk();
|
final timeSortedCommits = walker.walk();
|
||||||
|
|
||||||
for (var i = 0; i < timeSortedCommits.length; i++) {
|
for (var i = 0; i < timeSortedCommits.length; i++) {
|
||||||
|
@ -161,28 +158,26 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('hides head', () {
|
test('hides head', () {
|
||||||
final head = repo.head;
|
|
||||||
final walker = RevWalk(repo);
|
final walker = RevWalk(repo);
|
||||||
|
|
||||||
walker.push(head.target);
|
walker.push(repo.head.target);
|
||||||
final commits = walker.walk();
|
final commits = walker.walk();
|
||||||
expect(commits.length, 6);
|
expect(commits.length, 6);
|
||||||
|
|
||||||
walker.push(head.target);
|
walker.push(repo.head.target);
|
||||||
walker.hideHead();
|
walker.hideHead();
|
||||||
final hiddenCommits = walker.walk();
|
final hiddenCommits = walker.walk();
|
||||||
expect(hiddenCommits.length, 0);
|
expect(hiddenCommits.length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('hides oids of reference with provided name', () {
|
test('hides oids of reference with provided name', () {
|
||||||
final head = repo.head;
|
|
||||||
final walker = RevWalk(repo);
|
final walker = RevWalk(repo);
|
||||||
|
|
||||||
walker.push(head.target);
|
walker.push(repo.head.target);
|
||||||
final commits = walker.walk();
|
final commits = walker.walk();
|
||||||
expect(commits.length, 6);
|
expect(commits.length, 6);
|
||||||
|
|
||||||
walker.push(head.target);
|
walker.push(repo.head.target);
|
||||||
walker.hideReference('refs/heads/master');
|
walker.hideReference('refs/heads/master');
|
||||||
final hiddenCommits = walker.walk();
|
final hiddenCommits = walker.walk();
|
||||||
expect(hiddenCommits.length, 0);
|
expect(hiddenCommits.length, 0);
|
||||||
|
@ -197,9 +192,8 @@ void main() {
|
||||||
|
|
||||||
test('resets walker', () {
|
test('resets walker', () {
|
||||||
final walker = RevWalk(repo);
|
final walker = RevWalk(repo);
|
||||||
final start = Oid.fromSHA(repo: repo, sha: log.first);
|
|
||||||
|
|
||||||
walker.push(start);
|
walker.push(repo[log.first]);
|
||||||
walker.reset();
|
walker.reset();
|
||||||
final commits = walker.walk();
|
final commits = walker.walk();
|
||||||
|
|
||||||
|
@ -209,15 +203,12 @@ void main() {
|
||||||
test('simplifies walker by enqueuing only first parent for each commit',
|
test('simplifies walker by enqueuing only first parent for each commit',
|
||||||
() {
|
() {
|
||||||
final walker = RevWalk(repo);
|
final walker = RevWalk(repo);
|
||||||
final start = Oid.fromSHA(repo: repo, sha: log.first);
|
|
||||||
|
|
||||||
walker.push(start);
|
walker.push(repo[log.first]);
|
||||||
walker.simplifyFirstParent();
|
walker.simplifyFirstParent();
|
||||||
final commits = walker.walk();
|
final commits = walker.walk();
|
||||||
|
|
||||||
for (var i = 0; i < commits.length; i++) {
|
expect(commits.length, 3);
|
||||||
expect(commits.length, 3);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to add new root for traversal and error occurs',
|
test('throws when trying to add new root for traversal and error occurs',
|
||||||
|
|
|
@ -68,8 +68,11 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('updates with provided init flag', () {
|
test('updates with provided init flag', () {
|
||||||
final submoduleFilePath =
|
final submoduleFilePath = p.join(
|
||||||
p.join(repo.workdir, testSubmodule, 'master.txt');
|
repo.workdir,
|
||||||
|
testSubmodule,
|
||||||
|
'master.txt',
|
||||||
|
);
|
||||||
expect(File(submoduleFilePath).existsSync(), false);
|
expect(File(submoduleFilePath).existsSync(), false);
|
||||||
|
|
||||||
Submodule.update(repo: repo, name: testSubmodule, init: true);
|
Submodule.update(repo: repo, name: testSubmodule, init: true);
|
||||||
|
|
|
@ -49,14 +49,13 @@ void main() {
|
||||||
offset: 180,
|
offset: 180,
|
||||||
);
|
);
|
||||||
final target = tag.target as Commit;
|
final target = tag.target as Commit;
|
||||||
final tagger = tag.tagger;
|
|
||||||
|
|
||||||
expect(tag.oid, tagOid);
|
expect(tag.oid, tagOid);
|
||||||
expect(tag.name, 'v0.2');
|
expect(tag.name, 'v0.2');
|
||||||
expect(tag.message, 'annotated tag\n');
|
expect(tag.message, 'annotated tag\n');
|
||||||
expect(tag.targetType, GitObject.commit);
|
expect(tag.targetType, GitObject.commit);
|
||||||
expect(target.message, 'add subdirectory file\n');
|
expect(target.message, 'add subdirectory file\n');
|
||||||
expect(tagger, signature);
|
expect(tag.tagger, signature);
|
||||||
expect(tag.toString(), contains('Tag{'));
|
expect(tag.toString(), contains('Tag{'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -81,14 +80,13 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
final newTag = Tag.lookup(repo: repo, oid: oid);
|
final newTag = Tag.lookup(repo: repo, oid: oid);
|
||||||
final tagger = newTag.tagger;
|
|
||||||
final newTagTarget = newTag.target as Commit;
|
final newTagTarget = newTag.target as Commit;
|
||||||
|
|
||||||
expect(newTag.oid, oid);
|
expect(newTag.oid, oid);
|
||||||
expect(newTag.name, tagName);
|
expect(newTag.name, tagName);
|
||||||
expect(newTag.message, message);
|
expect(newTag.message, message);
|
||||||
expect(newTag.targetOid.sha, targetSHA);
|
expect(newTag.targetOid.sha, targetSHA);
|
||||||
expect(tagger, signature);
|
expect(newTag.tagger, signature);
|
||||||
expect(newTagTarget.oid, target);
|
expect(newTagTarget.oid, target);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -129,13 +127,12 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
final newTag = Tag.lookup(repo: repo, oid: oid);
|
final newTag = Tag.lookup(repo: repo, oid: oid);
|
||||||
final tagger = newTag.tagger;
|
|
||||||
final newTagTarget = newTag.target as Tree;
|
final newTagTarget = newTag.target as Tree;
|
||||||
|
|
||||||
expect(newTag.oid, oid);
|
expect(newTag.oid, oid);
|
||||||
expect(newTag.name, tagName);
|
expect(newTag.name, tagName);
|
||||||
expect(newTag.message, message);
|
expect(newTag.message, message);
|
||||||
expect(tagger, signature);
|
expect(newTag.tagger, signature);
|
||||||
expect(newTagTarget.oid, target);
|
expect(newTagTarget.oid, target);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -176,13 +173,12 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
final newTag = Tag.lookup(repo: repo, oid: oid);
|
final newTag = Tag.lookup(repo: repo, oid: oid);
|
||||||
final tagger = newTag.tagger;
|
|
||||||
final newTagTarget = newTag.target as Blob;
|
final newTagTarget = newTag.target as Blob;
|
||||||
|
|
||||||
expect(newTag.oid, oid);
|
expect(newTag.oid, oid);
|
||||||
expect(newTag.name, tagName);
|
expect(newTag.name, tagName);
|
||||||
expect(newTag.message, message);
|
expect(newTag.message, message);
|
||||||
expect(tagger, signature);
|
expect(newTag.tagger, signature);
|
||||||
expect(newTagTarget.oid, target);
|
expect(newTagTarget.oid, target);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -222,13 +218,12 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
final newTag = Tag.lookup(repo: repo, oid: oid);
|
final newTag = Tag.lookup(repo: repo, oid: oid);
|
||||||
final tagger = newTag.tagger;
|
|
||||||
final newTagTarget = newTag.target as Tag;
|
final newTagTarget = newTag.target as Tag;
|
||||||
|
|
||||||
expect(newTag.oid, oid);
|
expect(newTag.oid, oid);
|
||||||
expect(newTag.name, tagName);
|
expect(newTag.name, tagName);
|
||||||
expect(newTag.message, message);
|
expect(newTag.message, message);
|
||||||
expect(tagger, signature);
|
expect(newTag.tagger, signature);
|
||||||
expect(newTagTarget.oid, tag.oid);
|
expect(newTagTarget.oid, tag.oid);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -275,14 +270,13 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
final newTag = Tag.lookup(repo: repo, oid: oid);
|
final newTag = Tag.lookup(repo: repo, oid: oid);
|
||||||
final tagger = newTag.tagger;
|
|
||||||
final newTagTarget = newTag.target as Commit;
|
final newTagTarget = newTag.target as Commit;
|
||||||
|
|
||||||
expect(newTag.oid, oid);
|
expect(newTag.oid, oid);
|
||||||
expect(newTag.name, tagName);
|
expect(newTag.name, tagName);
|
||||||
expect(newTag.message, message);
|
expect(newTag.message, message);
|
||||||
expect(newTag.targetOid.sha, targetSHA);
|
expect(newTag.targetOid.sha, targetSHA);
|
||||||
expect(tagger, signature);
|
expect(newTag.tagger, signature);
|
||||||
expect(newTagTarget.oid, target);
|
expect(newTagTarget.oid, target);
|
||||||
expect(repo.tags.length, equals(2));
|
expect(repo.tags.length, equals(2));
|
||||||
});
|
});
|
||||||
|
|
|
@ -32,11 +32,10 @@ void main() {
|
||||||
|
|
||||||
test('initializes tree builder with provided tree', () {
|
test('initializes tree builder with provided tree', () {
|
||||||
final builder = TreeBuilder(repo: repo, tree: tree);
|
final builder = TreeBuilder(repo: repo, tree: tree);
|
||||||
final oid = builder.write();
|
|
||||||
|
|
||||||
expect(builder, isA<TreeBuilder>());
|
expect(builder, isA<TreeBuilder>());
|
||||||
expect(builder.length, tree.length);
|
expect(builder.length, tree.length);
|
||||||
expect(oid, tree.oid);
|
expect(builder.write(), tree.oid);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to initialize and error occurs', () {
|
test('throws when trying to initialize and error occurs', () {
|
||||||
|
|
|
@ -49,11 +49,10 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates worktree at provided path from provided reference', () {
|
test('creates worktree at provided path from provided reference', () {
|
||||||
final head = RevParse.single(repo: repo, spec: 'HEAD') as Commit;
|
|
||||||
final worktreeBranch = Branch.create(
|
final worktreeBranch = Branch.create(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
name: 'v1',
|
name: 'v1',
|
||||||
target: head,
|
target: RevParse.single(repo: repo, spec: 'HEAD') as Commit,
|
||||||
);
|
);
|
||||||
final ref = Reference.lookup(repo: repo, name: 'refs/heads/v1');
|
final ref = Reference.lookup(repo: repo, name: 'refs/heads/v1');
|
||||||
expect(repo.worktrees, <String>[]);
|
expect(repo.worktrees, <String>[]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue