refactor(merge)!: add MergeAnalysis class containing analysis result and merge preference (#49)

BREAKING CHANGE: Return value of Merge.analysis(...) changed from List<Object> to MergeAnalysis.
This commit is contained in:
Aleksey Kulikov 2022-04-28 18:00:18 +03:00 committed by GitHub
parent 9d61584165
commit 6d1ccd5c12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 21 deletions

View file

@ -26,23 +26,19 @@ void main() {
group('Merge', () {
group('analysis', () {
test('is up to date when no reference is provided', () {
expect(
Merge.analysis(repo: repo, theirHead: repo['c68ff54']),
[
{GitMergeAnalysis.upToDate},
GitMergePreference.none,
],
);
final analysis = Merge.analysis(repo: repo, theirHead: repo['c68ff54']);
expect(analysis.result, {GitMergeAnalysis.upToDate});
expect(analysis.mergePreference, GitMergePreference.none);
expect(repo.status, isEmpty);
});
test('is up to date for provided ref', () {
final result = Merge.analysis(
final analysis = Merge.analysis(
repo: repo,
theirHead: repo['c68ff54'],
ourRef: 'refs/tags/v0.1',
);
expect(result[0], {GitMergeAnalysis.upToDate});
expect(analysis.result, {GitMergeAnalysis.upToDate});
expect(repo.status, isEmpty);
});
@ -53,21 +49,21 @@ void main() {
target: Commit.lookup(repo: repo, oid: repo['f17d0d4']),
);
final result = Merge.analysis(
final analysis = Merge.analysis(
repo: repo,
theirHead: repo['6cbc22e'],
ourRef: 'refs/heads/${ffBranch.name}',
);
expect(
result[0],
analysis.result,
{GitMergeAnalysis.fastForward, GitMergeAnalysis.normal},
);
expect(repo.status, isEmpty);
});
test('is not fast forward and there is no conflicts', () {
final result = Merge.analysis(repo: repo, theirHead: repo['5aecfa0']);
expect(result[0], {GitMergeAnalysis.normal});
final analysis = Merge.analysis(repo: repo, theirHead: repo['5aecfa0']);
expect(analysis.result, {GitMergeAnalysis.normal});
expect(repo.status, isEmpty);
});
});
@ -76,11 +72,11 @@ void main() {
final conflictBranch = Branch.lookup(repo: repo, name: 'conflict-branch');
final index = repo.index;
final result = Merge.analysis(
final analysis = Merge.analysis(
repo: repo,
theirHead: conflictBranch.target,
);
expect(result[0], {GitMergeAnalysis.normal});
expect(analysis.result, {GitMergeAnalysis.normal});
Merge.commit(
repo: repo,