mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
feat(merge): add bindings and api for merge analysis
This commit is contained in:
parent
1f2d00b177
commit
223cc7cc14
5 changed files with 231 additions and 13 deletions
85
test/merge_test.dart
Normal file
85
test/merge_test.dart
Normal file
|
@ -0,0 +1,85 @@
|
|||
import 'dart:io';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'helpers/util.dart';
|
||||
|
||||
void main() {
|
||||
late Repository repo;
|
||||
final tmpDir = '${Directory.systemTemp.path}/merge_testrepo/';
|
||||
|
||||
setUp(() async {
|
||||
if (await Directory(tmpDir).exists()) {
|
||||
await Directory(tmpDir).delete(recursive: true);
|
||||
}
|
||||
await copyRepo(
|
||||
from: Directory('test/assets/testrepo/'),
|
||||
to: await Directory(tmpDir).create(),
|
||||
);
|
||||
repo = Repository.open(tmpDir);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
repo.free();
|
||||
await Directory(tmpDir).delete(recursive: true);
|
||||
});
|
||||
|
||||
group('Merge', () {
|
||||
group('analysis', () {
|
||||
test('is up to date when no reference is provided', () {
|
||||
final commit =
|
||||
repo['c68ff54aabf660fcdd9a2838d401583fe31249e3'] as Commit;
|
||||
final result = repo.mergeAnalysis(commit.id);
|
||||
|
||||
expect(result[0], GitMergeAnalysis.upToDate.value);
|
||||
expect(repo.status, isEmpty);
|
||||
|
||||
commit.free();
|
||||
});
|
||||
|
||||
test('is up to date for provided ref', () {
|
||||
final commit =
|
||||
repo['c68ff54aabf660fcdd9a2838d401583fe31249e3'] as Commit;
|
||||
final result = repo.mergeAnalysis(commit.id, 'refs/tags/v0.1');
|
||||
|
||||
expect(result[0], GitMergeAnalysis.upToDate.value);
|
||||
expect(repo.status, isEmpty);
|
||||
|
||||
commit.free();
|
||||
});
|
||||
|
||||
test('is fast forward', () {
|
||||
final theirHead =
|
||||
repo['6cbc22e509d72758ab4c8d9f287ea846b90c448b'] as Commit;
|
||||
final ffCommit =
|
||||
repo['f17d0d48eae3aa08cecf29128a35e310c97b3521'] as Commit;
|
||||
final ffBranch = repo.branches.create(
|
||||
name: 'ff-branch',
|
||||
target: ffCommit,
|
||||
);
|
||||
|
||||
final result = repo.mergeAnalysis(theirHead.id, ffBranch.name);
|
||||
|
||||
expect(
|
||||
result[0],
|
||||
GitMergeAnalysis.fastForward.value + GitMergeAnalysis.normal.value,
|
||||
);
|
||||
expect(repo.status, isEmpty);
|
||||
|
||||
ffBranch.free();
|
||||
ffCommit.free();
|
||||
theirHead.free();
|
||||
});
|
||||
|
||||
test('is not fast forward and there is no conflicts', () {
|
||||
final commit =
|
||||
repo['5aecfa0fb97eadaac050ccb99f03c3fb65460ad4'] as Commit;
|
||||
final result = repo.mergeAnalysis(commit.id);
|
||||
|
||||
expect(result[0], GitMergeAnalysis.normal.value);
|
||||
expect(repo.status, isEmpty);
|
||||
|
||||
commit.free();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue