From 0369df0ba130122a889952f7a44ae42e07b4efbd Mon Sep 17 00:00:00 2001 From: Florian Heck <florian.heck@hotmail.de> Date: Wed, 19 Oct 2016 12:28:49 +0200 Subject: [PATCH] changed merge to return current status --- .../fim/seibt/gitwrapper/repo/Reference.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Reference.java b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Reference.java index d44394d..853c05a 100644 --- a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Reference.java +++ b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Reference.java @@ -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)); } -- GitLab