mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
feat(merge): add ability to merge file from index
This commit is contained in:
parent
5c8d6647eb
commit
52707dcc63
4 changed files with 87 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
// ignore_for_file: unnecessary_string_escapes
|
||||
|
||||
import 'dart:io';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
|
@ -139,6 +141,35 @@ void main() {
|
|||
conflictBranch.free();
|
||||
});
|
||||
|
||||
group('merge file from index', () {
|
||||
test('successfully merges', () {
|
||||
const diffExpected = """
|
||||
\<<<<<<< conflict_file
|
||||
master conflict edit
|
||||
=======
|
||||
conflict branch edit
|
||||
>>>>>>> conflict_file
|
||||
""";
|
||||
final conflictBranch = repo.branches['conflict-branch'];
|
||||
final index = repo.index;
|
||||
repo.merge(conflictBranch.target);
|
||||
|
||||
final diff = repo.mergeFileFromIndex(
|
||||
ancestor: index.conflicts['conflict_file']!.ancestor,
|
||||
ours: index.conflicts['conflict_file']!.our,
|
||||
theirs: index.conflicts['conflict_file']!.their,
|
||||
);
|
||||
|
||||
expect(
|
||||
diff,
|
||||
diffExpected,
|
||||
);
|
||||
|
||||
index.free();
|
||||
conflictBranch.free();
|
||||
});
|
||||
});
|
||||
|
||||
group('merge commits', () {
|
||||
test('successfully merges with default values', () {
|
||||
final theirCommit =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue