diff --git a/plugins/git4idea/tests/git4idea/test/GitTestUtil.java b/plugins/git4idea/tests/git4idea/test/GitTestUtil.java index 57e62918531b..d16b88a0db01 100644 --- a/plugins/git4idea/tests/git4idea/test/GitTestUtil.java +++ b/plugins/git4idea/tests/git4idea/test/GitTestUtil.java @@ -22,7 +22,6 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl; import com.intellij.openapi.vfs.LocalFileSystem; @@ -41,16 +40,15 @@ import org.picocontainer.MutablePicoContainer; import java.io.File; import java.io.IOException; +import java.util.Arrays; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; -import static com.intellij.openapi.vcs.Executor.append; +import static com.intellij.openapi.util.text.StringUtil.splitByLines; +import static com.intellij.openapi.vcs.Executor.*; import static com.intellij.openapi.vcs.Executor.cd; -import static com.intellij.openapi.vcs.Executor.mkdir; -import static com.intellij.openapi.vcs.Executor.touch; import static git4idea.test.GitExecutor.*; -import static git4idea.test.GitExecutor.git; -import static git4idea.test.GitExecutor.last; import static junit.framework.Assert.assertNotNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -172,7 +170,7 @@ public class GitTestUtil { @NotNull public static Set readAllRefs(@NotNull VirtualFile root, @NotNull VcsLogObjectsFactory objectsFactory) { - String[] refs = StringUtil.splitByLines(git("log --branches --tags --no-walk --format=%H%d --decorate=full")); + String[] refs = splitByLines(git("log --branches --tags --no-walk --format=%H%d --decorate=full")); Set result = ContainerUtil.newHashSet(); for (String ref : refs) { result.addAll(new RefParser(objectsFactory).parseCommitRefs(ref, root)); @@ -199,7 +197,11 @@ public class GitTestUtil { @NotNull public static String cleanupForAssertion(@NotNull String content) { - return content.replace("
", "\n").replace("\n", " ").replaceAll("[ ]{2,}", " ").replaceAll(" href='[^']*'", "").trim(); + String nobr = content.replace("
", "\n").replace("
", "\n"); + return Arrays.stream(splitByLines(nobr)) + .map(line -> line.replaceAll(" href='[^']*'", "").trim()) + .filter(line -> !line.isEmpty()) + .collect(Collectors.joining(" ")); } @NotNull