Skip to content
Snippets Groups Projects
Commit 6de2af2f authored by Florian Heck's avatar Florian Heck
Browse files

Let a merge return the number of merge conflicts.

parent 202b5b5d
No related branches found
No related tags found
1 merge request!5Changes necessary for JDime wrapper script
package de.uni_passau.fim.gitwrapper;
import java.util.Optional;
import de.uni_passau.fim.processexecutor.ProcessExecutor;
import java.util.Optional;
/**
* A {@link MergeStrategy} representing the default 'git merge' merge implementation.
*/
......@@ -23,9 +23,9 @@ public class DefaultMergeStrategy implements MergeStrategy {
}
@Override
public Optional<Status> merge(Reference left, Reference right) {
public Optional<Integer> merge(Reference left, Reference right) {
Optional<ProcessExecutor.ExecRes> mergeBase = repo.getGit().exec(repo.getDir(), "merge", "-n", "-q", right.getId());
return mergeBase.flatMap(res -> repo.getStatus());
return mergeBase.flatMap(res -> repo.getStatus().map(stat -> stat.unmerged.size()));
}
@Override
......
......@@ -12,7 +12,7 @@ public interface MergeStrategy {
* the left parent of the merge
* @param right
* the right parent of the merge
* @return optionally the {@link Status} of the working directory after the merge, if the merge was successful
* @return optionally the number of merge conflicts after the merge, if the merge was successful
*/
Optional<Status> merge(Reference left, Reference right);
Optional<Integer> merge(Reference left, Reference right);
}
package de.uni_passau.fim.gitwrapper;
import de.uni_passau.fim.processexecutor.ProcessExecutor;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
......@@ -8,8 +10,6 @@ import java.util.function.Function;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import de.uni_passau.fim.processexecutor.ProcessExecutor;
/**
* A git object referencing a tree-ish object.
*
......@@ -92,9 +92,9 @@ public abstract class Reference {
* the {@link Reference} to merge
* @param strategy
* the {@link MergeStrategy} to use for merging
* @return the {@link Status} of the working directory after the merge
* @return optionally the number of merge conflicts after the merge, if the merge was successful
*/
public Optional<Status> merge(Reference other, MergeStrategy strategy) {
public Optional<Integer> merge(Reference other, MergeStrategy strategy) {
if (!repo.checkout(this)) {
return Optional.empty();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment