mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat(annotated)!: add more bindings and API methods (#26)
This commit is contained in:
parent
0176b66ba7
commit
fe570a6990
13 changed files with 498 additions and 146 deletions
118
test/annotated_test.dart
Normal file
118
test/annotated_test.dart
Normal file
|
@ -0,0 +1,118 @@
|
|||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'helpers/util.dart';
|
||||
|
||||
void main() {
|
||||
late Repository repo;
|
||||
late Directory tmpDir;
|
||||
late Oid tip;
|
||||
|
||||
setUp(() {
|
||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
||||
repo = Repository.open(tmpDir.path);
|
||||
tip = repo['821ed6e80627b8769d170a293862f9fc60825226'];
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
repo.free();
|
||||
tmpDir.deleteSync(recursive: true);
|
||||
});
|
||||
|
||||
group('AnnotatedCommit', () {
|
||||
test('lookups annotated commit from provided oid', () {
|
||||
final annotated = AnnotatedCommit.lookup(repo: repo, oid: tip);
|
||||
|
||||
expect(annotated.oid, tip);
|
||||
expect(annotated.refName, '');
|
||||
|
||||
annotated.free();
|
||||
});
|
||||
|
||||
test('throws when trying to lookup annotated commit with invalid oid', () {
|
||||
expect(
|
||||
() => AnnotatedCommit.lookup(repo: repo, oid: repo['0' * 40]),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
});
|
||||
|
||||
test('creates annotated commit from provided reference', () {
|
||||
final reference = repo.lookupReference('refs/heads/master');
|
||||
final annotated = AnnotatedCommit.fromReference(
|
||||
repo: repo,
|
||||
reference: reference,
|
||||
);
|
||||
|
||||
expect(annotated.oid, reference.target);
|
||||
expect(annotated.refName, 'refs/heads/master');
|
||||
|
||||
annotated.free();
|
||||
reference.free();
|
||||
});
|
||||
|
||||
test(
|
||||
'throws when trying to create annotated commit from provided '
|
||||
'reference and error occurs', () {
|
||||
final reference = repo.lookupReference('refs/heads/master');
|
||||
|
||||
expect(
|
||||
() => AnnotatedCommit.fromReference(
|
||||
repo: Repository(nullptr),
|
||||
reference: reference,
|
||||
),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
|
||||
reference.free();
|
||||
});
|
||||
|
||||
test('creates annotated commit from provided revspec', () {
|
||||
final annotated = AnnotatedCommit.fromRevSpec(repo: repo, spec: '@{-1}');
|
||||
|
||||
expect(annotated.oid.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
||||
expect(annotated.refName, '');
|
||||
|
||||
annotated.free();
|
||||
});
|
||||
|
||||
test('throws when trying to create annotated commit from invalid revspec',
|
||||
() {
|
||||
expect(
|
||||
() => AnnotatedCommit.fromRevSpec(repo: repo, spec: 'invalid'),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
});
|
||||
|
||||
test('creates annotated commit from provided fetch head data', () {
|
||||
final oid = repo['821ed6e'];
|
||||
final annotated = AnnotatedCommit.fromFetchHead(
|
||||
repo: repo,
|
||||
branchName: 'master',
|
||||
remoteUrl: 'git://github.com/SkinnyMind/libgit2dart.git',
|
||||
oid: oid,
|
||||
);
|
||||
|
||||
expect(annotated.oid, oid);
|
||||
expect(annotated.refName, 'master');
|
||||
|
||||
annotated.free();
|
||||
});
|
||||
|
||||
test(
|
||||
'throws when trying to create annotated commit from fetch head and '
|
||||
'error occurs', () {
|
||||
expect(
|
||||
() => AnnotatedCommit.fromFetchHead(
|
||||
repo: repo,
|
||||
branchName: '',
|
||||
remoteUrl: '',
|
||||
oid: Oid(nullptr),
|
||||
),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -57,19 +57,6 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
test('successfully lookups annotated commit for provided oid', () {
|
||||
final annotated = AnnotatedCommit.lookup(repo: repo, oid: tip);
|
||||
expect(annotated, isA<AnnotatedCommit>());
|
||||
annotated.free();
|
||||
});
|
||||
|
||||
test('throws when trying to lookup annotated commit with invalid oid', () {
|
||||
expect(
|
||||
() => AnnotatedCommit.lookup(repo: repo, oid: repo['0' * 40]),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'throws when trying to get the summary of the commit message and error '
|
||||
'occurs', () {
|
||||
|
|
|
@ -311,10 +311,16 @@ void main() {
|
|||
|
||||
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
||||
final index = repo.index;
|
||||
repo.merge(oid: conflictBranch.target);
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: repo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
|
||||
repo.merge(commit: commit);
|
||||
|
||||
expect(() => index.writeTree(), throwsA(isA<LibGit2Error>()));
|
||||
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
index.free();
|
||||
repo.free();
|
||||
|
@ -341,10 +347,14 @@ void main() {
|
|||
final conflictBranch = conflictRepo.lookupBranch(
|
||||
name: 'ancestor-conflict',
|
||||
);
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: conflictRepo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
|
||||
conflictRepo.checkout(refName: 'refs/heads/feature');
|
||||
|
||||
conflictRepo.merge(oid: conflictBranch.target);
|
||||
conflictRepo.merge(commit: commit);
|
||||
|
||||
final index = conflictRepo.index;
|
||||
final conflictedFile = index.conflicts['feature_file']!;
|
||||
|
@ -354,6 +364,7 @@ void main() {
|
|||
expect(conflictedFile.toString(), contains('ConflictEntry{'));
|
||||
|
||||
index.free();
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
conflictRepo.free();
|
||||
repoDir.deleteSync(recursive: true);
|
||||
|
@ -364,8 +375,12 @@ void main() {
|
|||
final conflictRepo = Repository.open(repoDir.path);
|
||||
|
||||
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: conflictRepo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
|
||||
conflictRepo.merge(oid: conflictBranch.target);
|
||||
conflictRepo.merge(commit: commit);
|
||||
|
||||
final index = conflictRepo.index;
|
||||
final conflictedFile = index.conflicts['conflict_file']!;
|
||||
|
@ -375,6 +390,7 @@ void main() {
|
|||
expect(conflictedFile.toString(), contains('ConflictEntry{'));
|
||||
|
||||
index.free();
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
conflictRepo.free();
|
||||
repoDir.deleteSync(recursive: true);
|
||||
|
@ -387,10 +403,14 @@ void main() {
|
|||
final conflictBranch = conflictRepo.lookupBranch(
|
||||
name: 'ancestor-conflict',
|
||||
);
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: conflictRepo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
|
||||
conflictRepo.checkout(refName: 'refs/heads/our-conflict');
|
||||
|
||||
conflictRepo.merge(oid: conflictBranch.target);
|
||||
conflictRepo.merge(commit: commit);
|
||||
|
||||
final index = conflictRepo.index;
|
||||
final conflictedFile = index.conflicts['feature_file']!;
|
||||
|
@ -400,6 +420,7 @@ void main() {
|
|||
expect(conflictedFile.toString(), contains('ConflictEntry{'));
|
||||
|
||||
index.free();
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
conflictRepo.free();
|
||||
repoDir.deleteSync(recursive: true);
|
||||
|
@ -410,10 +431,14 @@ void main() {
|
|||
final conflictRepo = Repository.open(repoDir.path);
|
||||
|
||||
final conflictBranch = conflictRepo.lookupBranch(name: 'their-conflict');
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: conflictRepo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
|
||||
conflictRepo.checkout(refName: 'refs/heads/feature');
|
||||
|
||||
conflictRepo.merge(oid: conflictBranch.target);
|
||||
conflictRepo.merge(commit: commit);
|
||||
|
||||
final index = conflictRepo.index;
|
||||
final conflictedFile = index.conflicts['feature_file']!;
|
||||
|
@ -423,6 +448,7 @@ void main() {
|
|||
expect(conflictedFile.toString(), contains('ConflictEntry{'));
|
||||
|
||||
index.free();
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
conflictRepo.free();
|
||||
repoDir.deleteSync(recursive: true);
|
||||
|
@ -433,9 +459,13 @@ void main() {
|
|||
final conflictRepo = Repository.open(repoDir.path);
|
||||
|
||||
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: conflictRepo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
final index = conflictRepo.index;
|
||||
|
||||
conflictRepo.merge(oid: conflictBranch.target);
|
||||
conflictRepo.merge(commit: commit);
|
||||
expect(index.hasConflicts, true);
|
||||
expect(index['.gitignore'].isConflict, false);
|
||||
expect(index.conflicts['conflict_file']!.our!.isConflict, true);
|
||||
|
@ -448,6 +478,7 @@ void main() {
|
|||
expect(index.conflicts['conflict_file'], null);
|
||||
|
||||
index.free();
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
conflictRepo.free();
|
||||
repoDir.deleteSync(recursive: true);
|
||||
|
@ -466,9 +497,13 @@ void main() {
|
|||
final conflictRepo = Repository.open(repoDir.path);
|
||||
|
||||
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: conflictRepo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
final index = conflictRepo.index;
|
||||
|
||||
conflictRepo.merge(oid: conflictBranch.target);
|
||||
conflictRepo.merge(commit: commit);
|
||||
expect(index.hasConflicts, true);
|
||||
expect(index.conflicts.length, 1);
|
||||
|
||||
|
@ -477,6 +512,7 @@ void main() {
|
|||
expect(index.conflicts, isEmpty);
|
||||
|
||||
index.free();
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
conflictRepo.free();
|
||||
repoDir.deleteSync(recursive: true);
|
||||
|
|
|
@ -72,12 +72,16 @@ void main() {
|
|||
|
||||
test('writes conflicts to index', () {
|
||||
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: repo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
final index = repo.index;
|
||||
|
||||
final result = repo.mergeAnalysis(theirHead: conflictBranch.target);
|
||||
expect(result[0], {GitMergeAnalysis.normal});
|
||||
|
||||
repo.merge(oid: conflictBranch.target);
|
||||
repo.merge(commit: commit);
|
||||
expect(index.hasConflicts, true);
|
||||
expect(index.conflicts.length, 1);
|
||||
expect(repo.state, GitRepositoryState.merge);
|
||||
|
@ -105,6 +109,7 @@ void main() {
|
|||
);
|
||||
|
||||
index.free();
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
});
|
||||
|
||||
|
@ -118,8 +123,13 @@ conflict branch edit
|
|||
>>>>>>> conflict_file
|
||||
""";
|
||||
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: repo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
final index = repo.index;
|
||||
repo.merge(oid: conflictBranch.target);
|
||||
|
||||
repo.merge(commit: commit);
|
||||
|
||||
final conflictedFile = index.conflicts['conflict_file']!;
|
||||
final diff = repo.mergeFileFromIndex(
|
||||
|
@ -131,6 +141,7 @@ conflict branch edit
|
|||
expect(diff, diffExpected);
|
||||
|
||||
index.free();
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
});
|
||||
|
||||
|
@ -143,9 +154,14 @@ Another feature edit
|
|||
>>>>>>> feature_file
|
||||
""";
|
||||
final conflictBranch = repo.lookupBranch(name: 'ancestor-conflict');
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: repo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
repo.checkout(refName: 'refs/heads/feature');
|
||||
final index = repo.index;
|
||||
repo.merge(oid: conflictBranch.target);
|
||||
|
||||
repo.merge(commit: commit);
|
||||
|
||||
final conflictedFile = index.conflicts['feature_file']!;
|
||||
final diff = repo.mergeFileFromIndex(
|
||||
|
@ -157,6 +173,7 @@ Another feature edit
|
|||
expect(diff, diffExpected);
|
||||
|
||||
index.free();
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
});
|
||||
|
||||
|
@ -169,9 +186,14 @@ conflict branch edit
|
|||
>>>>>>> conflict_file
|
||||
""";
|
||||
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
||||
final index = repo.index;
|
||||
repo.merge(
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: repo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
final index = repo.index;
|
||||
|
||||
repo.merge(
|
||||
commit: commit,
|
||||
mergeFlags: {GitMergeFlag.noRecursive},
|
||||
fileFlags: {GitMergeFileFlag.ignoreWhitespaceEOL},
|
||||
);
|
||||
|
@ -186,14 +208,20 @@ conflict branch edit
|
|||
expect(diff, diffExpected);
|
||||
|
||||
index.free();
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
});
|
||||
|
||||
test('merges with provided merge favor', () {
|
||||
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
||||
final commit = AnnotatedCommit.lookup(
|
||||
repo: repo,
|
||||
oid: conflictBranch.target,
|
||||
);
|
||||
final index = repo.index;
|
||||
|
||||
repo.merge(oid: conflictBranch.target, favor: GitMergeFileFavor.ours);
|
||||
repo.merge(commit: commit, favor: GitMergeFileFavor.ours);
|
||||
|
||||
expect(index.conflicts, isEmpty);
|
||||
expect(
|
||||
File('${repo.workdir}conflict_file').readAsStringSync(),
|
||||
|
@ -201,6 +229,7 @@ conflict branch edit
|
|||
);
|
||||
|
||||
index.free();
|
||||
commit.free();
|
||||
conflictBranch.free();
|
||||
});
|
||||
|
||||
|
@ -274,6 +303,10 @@ theirs content
|
|||
group('merge commits', () {
|
||||
test('successfully merges with default values', () {
|
||||
final theirCommit = repo.lookupCommit(repo['5aecfa0']);
|
||||
final theirCommitAnnotated = AnnotatedCommit.lookup(
|
||||
repo: repo,
|
||||
oid: theirCommit.oid,
|
||||
);
|
||||
final ourCommit = repo.lookupCommit(repo['1490545']);
|
||||
|
||||
final mergeIndex = repo.mergeCommits(
|
||||
|
@ -283,7 +316,7 @@ theirs content
|
|||
expect(mergeIndex.conflicts, isEmpty);
|
||||
final mergeCommitsTree = mergeIndex.writeTree(repo);
|
||||
|
||||
repo.merge(oid: theirCommit.oid);
|
||||
repo.merge(commit: theirCommitAnnotated);
|
||||
final index = repo.index;
|
||||
expect(index.conflicts, isEmpty);
|
||||
final mergeTree = index.writeTree();
|
||||
|
@ -293,6 +326,7 @@ theirs content
|
|||
index.free();
|
||||
mergeIndex.free();
|
||||
ourCommit.free();
|
||||
theirCommitAnnotated.free();
|
||||
theirCommit.free();
|
||||
});
|
||||
|
||||
|
@ -420,6 +454,10 @@ theirs content
|
|||
group('merge trees', () {
|
||||
test('successfully merges with default values', () {
|
||||
final theirCommit = repo.lookupCommit(repo['5aecfa0']);
|
||||
final theirCommitAnnotated = AnnotatedCommit.lookup(
|
||||
repo: repo,
|
||||
oid: theirCommit.oid,
|
||||
);
|
||||
final ourCommit = repo.lookupCommit(repo['1490545']);
|
||||
final baseCommit = repo.lookupCommit(
|
||||
repo.mergeBase([ourCommit.oid, theirCommit.oid]),
|
||||
|
@ -437,7 +475,7 @@ theirs content
|
|||
final mergeTreesTree = mergeIndex.writeTree(repo);
|
||||
|
||||
repo.setHead(ourCommit.oid);
|
||||
repo.merge(oid: theirCommit.oid);
|
||||
repo.merge(commit: theirCommitAnnotated);
|
||||
final index = repo.index;
|
||||
expect(index.conflicts, isEmpty);
|
||||
final mergeTree = index.writeTree();
|
||||
|
@ -451,6 +489,7 @@ theirs content
|
|||
theirTree.free();
|
||||
baseCommit.free();
|
||||
ourCommit.free();
|
||||
theirCommitAnnotated.free();
|
||||
theirCommit.free();
|
||||
});
|
||||
|
||||
|
|
|
@ -32,15 +32,17 @@ void main() {
|
|||
time: 1234,
|
||||
);
|
||||
final master = repo.lookupReference('refs/heads/master');
|
||||
final branchHead = AnnotatedCommit.lookup(repo: repo, oid: master.target);
|
||||
final feature = repo.lookupReference('refs/heads/feature');
|
||||
final ontoHead = AnnotatedCommit.lookup(repo: repo, oid: feature.target);
|
||||
|
||||
repo.checkout(refName: feature.name);
|
||||
expect(() => repo.index['.gitignore'], throwsA(isA<ArgumentError>()));
|
||||
|
||||
final rebase = Rebase.init(
|
||||
repo: repo,
|
||||
branch: master.target,
|
||||
onto: feature.target,
|
||||
branch: branchHead,
|
||||
onto: ontoHead,
|
||||
);
|
||||
|
||||
final operationsCount = rebase.operationsCount;
|
||||
|
@ -63,6 +65,8 @@ void main() {
|
|||
expect(repo.index['.gitignore'], isA<IndexEntry>());
|
||||
|
||||
rebase.free();
|
||||
ontoHead.free();
|
||||
branchHead.free();
|
||||
feature.free();
|
||||
master.free();
|
||||
signature.free();
|
||||
|
@ -75,10 +79,11 @@ void main() {
|
|||
time: 1234,
|
||||
);
|
||||
final feature = repo.lookupReference('refs/heads/feature');
|
||||
final ontoHead = AnnotatedCommit.lookup(repo: repo, oid: feature.target);
|
||||
|
||||
final rebase = Rebase.init(
|
||||
repo: repo,
|
||||
onto: feature.target,
|
||||
onto: ontoHead,
|
||||
);
|
||||
|
||||
final operationsCount = rebase.operationsCount;
|
||||
|
@ -100,6 +105,7 @@ void main() {
|
|||
rebase.finish();
|
||||
|
||||
rebase.free();
|
||||
ontoHead.free();
|
||||
feature.free();
|
||||
signature.free();
|
||||
});
|
||||
|
@ -111,16 +117,17 @@ void main() {
|
|||
time: 1234,
|
||||
);
|
||||
final master = repo.lookupReference('refs/heads/master');
|
||||
final branchHead = AnnotatedCommit.lookup(repo: repo, oid: master.target);
|
||||
final feature = repo.lookupReference('refs/heads/feature');
|
||||
final startCommit = repo.lookupCommit(repo[shas[1]]);
|
||||
final upstream = AnnotatedCommit.lookup(repo: repo, oid: repo[shas[1]]);
|
||||
|
||||
repo.checkout(refName: feature.name);
|
||||
expect(() => repo.index['conflict_file'], throwsA(isA<ArgumentError>()));
|
||||
|
||||
final rebase = Rebase.init(
|
||||
repo: repo,
|
||||
branch: master.target,
|
||||
upstream: startCommit.oid,
|
||||
branch: branchHead,
|
||||
upstream: upstream,
|
||||
);
|
||||
|
||||
final operationsCount = rebase.operationsCount;
|
||||
|
@ -135,7 +142,8 @@ void main() {
|
|||
expect(repo.index['conflict_file'], isA<IndexEntry>());
|
||||
|
||||
rebase.free();
|
||||
startCommit.free();
|
||||
upstream.free();
|
||||
branchHead.free();
|
||||
feature.free();
|
||||
master.free();
|
||||
signature.free();
|
||||
|
@ -154,14 +162,16 @@ void main() {
|
|||
time: 1234,
|
||||
);
|
||||
final master = repo.lookupReference('refs/heads/master');
|
||||
final branchHead = AnnotatedCommit.lookup(repo: repo, oid: master.target);
|
||||
final conflict = repo.lookupReference('refs/heads/conflict-branch');
|
||||
final ontoHead = AnnotatedCommit.lookup(repo: repo, oid: conflict.target);
|
||||
|
||||
repo.checkout(refName: conflict.name);
|
||||
|
||||
final rebase = Rebase.init(
|
||||
repo: repo,
|
||||
branch: master.target,
|
||||
onto: conflict.target,
|
||||
branch: branchHead,
|
||||
onto: ontoHead,
|
||||
);
|
||||
expect(rebase.operationsCount, 1);
|
||||
|
||||
|
@ -174,6 +184,8 @@ void main() {
|
|||
);
|
||||
|
||||
rebase.free();
|
||||
ontoHead.free();
|
||||
branchHead.free();
|
||||
conflict.free();
|
||||
master.free();
|
||||
signature.free();
|
||||
|
@ -187,14 +199,16 @@ void main() {
|
|||
time: 1234,
|
||||
);
|
||||
final master = repo.lookupReference('refs/heads/master');
|
||||
final branchHead = AnnotatedCommit.lookup(repo: repo, oid: master.target);
|
||||
final conflict = repo.lookupReference('refs/heads/conflict-branch');
|
||||
final ontoHead = AnnotatedCommit.lookup(repo: repo, oid: conflict.target);
|
||||
|
||||
repo.checkout(refName: conflict.name);
|
||||
|
||||
final rebase = Rebase.init(
|
||||
repo: repo,
|
||||
branch: master.target,
|
||||
onto: conflict.target,
|
||||
branch: branchHead,
|
||||
onto: ontoHead,
|
||||
);
|
||||
expect(rebase.operationsCount, 1);
|
||||
|
||||
|
@ -202,6 +216,8 @@ void main() {
|
|||
expect(() => rebase.next(), throwsA(isA<LibGit2Error>()));
|
||||
|
||||
rebase.free();
|
||||
ontoHead.free();
|
||||
branchHead.free();
|
||||
conflict.free();
|
||||
master.free();
|
||||
signature.free();
|
||||
|
@ -209,14 +225,16 @@ void main() {
|
|||
|
||||
test('successfully aborts rebase in progress', () {
|
||||
final master = repo.lookupReference('refs/heads/master');
|
||||
final branchHead = AnnotatedCommit.lookup(repo: repo, oid: master.target);
|
||||
final conflict = repo.lookupReference('refs/heads/conflict-branch');
|
||||
final ontoHead = AnnotatedCommit.lookup(repo: repo, oid: conflict.target);
|
||||
|
||||
repo.checkout(refName: conflict.name);
|
||||
|
||||
final rebase = Rebase.init(
|
||||
repo: repo,
|
||||
branch: master.target,
|
||||
onto: conflict.target,
|
||||
branch: branchHead,
|
||||
onto: ontoHead,
|
||||
);
|
||||
expect(rebase.operationsCount, 1);
|
||||
|
||||
|
@ -229,6 +247,8 @@ void main() {
|
|||
expect(repo.state, GitRepositoryState.none);
|
||||
|
||||
rebase.free();
|
||||
ontoHead.free();
|
||||
branchHead.free();
|
||||
conflict.free();
|
||||
master.free();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue