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

changed merge to return current status

parent 200e1ed4
No related branches found
No related tags found
No related merge requests found
......@@ -65,25 +65,14 @@ public abstract class Reference {
* part of the same {@link Repository} this {@link Reference} is.
*
* @param other the {@link Reference} to merge
* @return <code>false</code>, if the merge failed, or contains conflicts.
* @return the {@link Status} of the working directory after the merge
*/
public boolean merge(Reference other) {
public Optional<Status> merge(Reference other) {
if (!repo.checkout(this)) {
return false;
return Optional.empty();
}
Optional<ProcessExecutor.ExecRes> mergeBase = git.exec(repo.getDir(), "merge", "-n", "-q", other.getId());
Function<ProcessExecutor.ExecRes, Boolean> toBoolean = res -> {
if (git.failed(res)) {
LOG.warning(() -> String.format("Failed to merge %s and %s.", this, other));
return null;
}
// if there is no conflict, quiet and no-stat produce no output
return res.stdOut.isEmpty();
};
return mergeBase.map(toBoolean).orElse(false);
return mergeBase.map(res -> repo.getStatus().orElse(null));
}
......
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