GitRootChecker: understand <Project> mapping

Store a mapping in VcsRootError, not a VirtualFile.
<Project> means that there are Git repositories amongst the VCS roots (i.e. content roots), not in the folders below the directory.
This commit is contained in:
Kirill Likhodedov
2012-03-13 19:03:52 +04:00
parent 6ccd409b3d
commit 4c54cf85e8
12 changed files with 228 additions and 90 deletions
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.vcs;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -29,14 +28,15 @@ import java.util.Collection;
public interface VcsRootChecker {
/**
* @return VCS roots which are not registered in the Settings | Version Control.
* @return Paths to VCS roots which are not registered in the Settings | Version Control.
*/
@NotNull
Collection<VirtualFile> getUnregisteredRoots();
Collection<String> getUnregisteredRoots();
/**
*
* @param directory root to be checked.
* @return true if the given directory is not a VCS root.
*/
boolean isInvalidRoot(@NotNull String directory);
boolean isInvalidMapping(@NotNull VcsDirectoryMapping mapping);
}
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.vcs;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
/**
@@ -29,16 +28,16 @@ import org.jetbrains.annotations.NotNull;
public class VcsRootError {
private final @NotNull Type myType;
private final @NotNull VirtualFile myRoot;
private final @NotNull String myMapping;
public enum Type {
EXTRA_ROOT,
EXTRA_MAPPING,
UNREGISTERED_ROOT
}
public VcsRootError(@NotNull Type type, @NotNull VirtualFile root) {
public VcsRootError(@NotNull Type type, @NotNull String mapping) {
myType = type;
myRoot = root;
myMapping = mapping;
}
@NotNull
@@ -47,13 +46,13 @@ public class VcsRootError {
}
@NotNull
public VirtualFile getRoot() {
return myRoot;
public String getMapping() {
return myMapping;
}
@Override
public String toString() {
return String.format("GitRootError{myType=%s, myRoot=%s}", myType, myRoot);
return String.format("VcsRootError{%s - %s}", myType, myMapping);
}
@Override
@@ -63,7 +62,7 @@ public class VcsRootError {
VcsRootError error = (VcsRootError)o;
if (!myRoot.equals(error.myRoot)) return false;
if (!myMapping.equals(error.myMapping)) return false;
if (myType != error.myType) return false;
return true;
@@ -73,7 +72,7 @@ public class VcsRootError {
@Override
public int hashCode() {
int result = myType != null ? myType.hashCode() : 0;
result = 31 * result + myRoot.hashCode();
result = 31 * result + myMapping.hashCode();
return result;
}
}
@@ -116,7 +116,7 @@ public class VcsDirectoryConfigurationPanel extends PanelWithButtons implements
private boolean mappingIsError(VcsDirectoryMapping mapping) {
String vcs = mapping.getVcs();
VcsRootChecker checker = myCheckers.get(vcs);
return checker != null && checker.isInvalidRoot(mapping.getDirectory());
return checker != null && checker.isInvalidMapping(mapping);
}
}
@@ -395,14 +395,14 @@ public class VcsDirectoryConfigurationPanel extends PanelWithButtons implements
Box box = Box.createVerticalBox();
for (Map.Entry<String, VcsRootChecker> entry : myCheckers.entrySet()) {
VcsRootChecker checker = entry.getValue();
for (final VirtualFile root : checker.getUnregisteredRoots()) {
for (final String root : checker.getUnregisteredRoots()) {
final String vcs = entry.getKey();
String title = "Unregistered " + vcs + " root: " + FileUtil.toSystemDependentName(root.getPresentableUrl());
String title = "Unregistered " + vcs + " root: " + FileUtil.toSystemDependentName(root);
final VcsRootErrorLabel vcsRootErrorLabel = new VcsRootErrorLabel(title);
vcsRootErrorLabel.setAddRootLinkHandler(new Runnable() {
@Override
public void run() {
addMapping(new VcsDirectoryMapping(root.getPath(), vcs));
addMapping(new VcsDirectoryMapping(root, vcs));
vcsRootErrorLabel.setVisible(false);
}
});
@@ -16,10 +16,9 @@
package git4idea.roots;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.VcsDirectoryMapping;
import com.intellij.openapi.vcs.VcsRootChecker;
import com.intellij.openapi.vcs.VcsRootError;
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.PlatformFacade;
import org.jetbrains.annotations.NotNull;
@@ -32,30 +31,44 @@ import java.util.Collection;
*/
public class GitRootChecker implements VcsRootChecker {
private final Collection<VcsRootError> myErrors;
@NotNull private final Collection<VcsRootError> myErrors;
private final boolean myProjectMappingIsInvalid;
public GitRootChecker(Project project, PlatformFacade platformFacade) {
public GitRootChecker(@NotNull Project project, @NotNull PlatformFacade platformFacade) {
myErrors = new GitRootErrorsFinder(project, platformFacade).find();
myProjectMappingIsInvalid = isProjectMappingInvalid();
}
private boolean isProjectMappingInvalid() {
for (VcsRootError error : myErrors) {
if (error.getType() == VcsRootError.Type.EXTRA_MAPPING && error.getMapping().equals(VcsDirectoryMapping.PROJECT_CONSTANT)) {
return true;
}
}
return false;
}
@NotNull
@Override
public Collection<VirtualFile> getUnregisteredRoots() {
Collection<VirtualFile> roots = new ArrayList<VirtualFile>();
public Collection<String> getUnregisteredRoots() {
Collection<String> roots = new ArrayList<String>();
for (VcsRootError error : myErrors) {
if (error.getType() == VcsRootError.Type.UNREGISTERED_ROOT) {
roots.add(error.getRoot());
roots.add(error.getMapping());
}
}
return roots;
}
@Override
public boolean isInvalidRoot(@NotNull String directory) {
public boolean isInvalidMapping(@NotNull VcsDirectoryMapping mapping) {
// this information is available in myErrors,
// but the method may be called in VcsDirectoryConfigurationPanel after adding a mapping (to highlight errors right away)
// in which case ProjectLevelVcsManager#getAllVcsRoots() is not aware of new roots yet,
// while GitRootErrorsFinder relies on the set of roots returned from ProjectLevelVcsManager.
return !new File(FileUtil.toSystemDependentName(directory), ".git").exists();
if (mapping.isDefaultMapping()) {
return myProjectMappingIsInvalid;
}
return !new File(mapping.getDirectory(), ".git").exists();
}
}
@@ -57,7 +57,7 @@ public class GitRootDetectInfo {
}
@NotNull
Collection<VirtualFile> getRoots() {
public Collection<VirtualFile> getRoots() {
return new ArrayList<VirtualFile>(myRoots);
}
@@ -16,7 +16,9 @@
package git4idea.roots;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsDirectoryMapping;
import com.intellij.openapi.vcs.VcsRootError;
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.PlatformFacade;
@@ -25,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* Detects actual Git roots and compares them to the ones registered in Settings | Version Control.
@@ -35,29 +38,63 @@ public class GitRootErrorsFinder {
private final @NotNull Project myProject;
private final @NotNull PlatformFacade myPlatformFacade;
private final @NotNull ProjectLevelVcsManager myVcsManager;
private final AbstractVcs myVcs;
public GitRootErrorsFinder(@NotNull Project project, @NotNull PlatformFacade platformFacade) {
myProject = project;
myPlatformFacade = platformFacade;
myVcsManager = myPlatformFacade.getVcsManager(myProject);
myVcs = myPlatformFacade.getVcs(myProject);
}
@NotNull
public Collection<VcsRootError> find() {
ProjectLevelVcsManager vcsManager = myPlatformFacade.getVcsManager(myProject);
Collection<VirtualFile> vcsRoots = Arrays.asList(vcsManager.getRootsUnderVcs(myPlatformFacade.getVcs(myProject)));
List<VcsDirectoryMapping> mappings = myVcsManager.getDirectoryMappings(myVcs);
Collection<VirtualFile> gitRoots = new GitRootDetector(myProject, myPlatformFacade).detect().getRoots();
Collection<VcsRootError> errors = new ArrayList<VcsRootError>();
for (VirtualFile vcsRoot : vcsRoots) {
if (!gitRoots.contains(vcsRoot)) {
errors.add(new VcsRootError(VcsRootError.Type.EXTRA_ROOT, vcsRoot));
}
}
errors.addAll(findExtraMappings(mappings, rootsToPaths(gitRoots)));
errors.addAll(findUnregisteredRoots(gitRoots));
return errors;
}
private Collection<VcsRootError> findUnregisteredRoots(Collection<VirtualFile> gitRoots) {
Collection<VcsRootError> errors = new ArrayList<VcsRootError>();
Collection<VirtualFile> vcsRoots = Arrays.asList(myVcsManager.getRootsUnderVcs(myVcs));
for (VirtualFile gitRoot : gitRoots) {
if (!vcsRoots.contains(gitRoot)) {
errors.add(new VcsRootError(VcsRootError.Type.UNREGISTERED_ROOT, gitRoot));
errors.add(new VcsRootError(VcsRootError.Type.UNREGISTERED_ROOT, gitRoot.getPath()));
}
}
return errors;
}
private static Collection<VcsRootError> findExtraMappings(List<VcsDirectoryMapping> mappings, Collection<String> gitPaths) {
Collection<VcsRootError> errors = new ArrayList<VcsRootError>();
for (VcsDirectoryMapping mapping : mappings) {
if (mapping.isDefaultMapping()) {
if (gitPaths.isEmpty()) {
errors.add(new VcsRootError(VcsRootError.Type.EXTRA_MAPPING, VcsDirectoryMapping.PROJECT_CONSTANT));
}
}
else {
String mappedPath = mapping.systemIndependentPath();
if (!gitPaths.contains(mappedPath)) {
errors.add(new VcsRootError(VcsRootError.Type.EXTRA_MAPPING, mappedPath));
}
}
}
return errors;
}
@NotNull
private static Collection<String> rootsToPaths(@NotNull Collection<VirtualFile> gitRoots) {
Collection<String> gitPaths = new ArrayList<String>(gitRoots.size());
for (VirtualFile root : gitRoots) {
gitPaths.add(root.getPath());
}
return gitPaths;
}
}
@@ -24,8 +24,8 @@ import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.VcsDirectoryMapping;
import com.intellij.openapi.vcs.VcsRootError;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Function;
import git4idea.PlatformFacade;
import org.jetbrains.annotations.NotNull;
@@ -73,8 +73,8 @@ public class GitRootProblemNotifier {
return;
}
Collection<VirtualFile> unregisteredRoots = getUnregisteredRoots(errors);
Collection<VirtualFile> invalidRoots = getInvalidRoots(errors);
Collection<String> unregisteredRoots = getUnregisteredRoots(errors);
Collection<String> invalidRoots = getInvalidRoots(errors);
String title = makeTitle(unregisteredRoots, invalidRoots);
String description = makeDescription(unregisteredRoots, invalidRoots);
@@ -106,35 +106,38 @@ public class GitRootProblemNotifier {
}
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
private static String makeDescription(@NotNull Collection<VirtualFile> unregisteredRoots, @NotNull Collection<VirtualFile> invalidRoots) {
Function<VirtualFile, String> rootToString = new Function<VirtualFile, String>() {
private static String makeDescription(@NotNull Collection<String> unregisteredRoots, @NotNull Collection<String> invalidRoots) {
Function<String, String> rootToDisplayableString = new Function<String, String>() {
@Override
public String fun(VirtualFile virtualFile) {
return FileUtil.toSystemDependentName(virtualFile.getPath());
public String fun(String path) {
if (path.equals(VcsDirectoryMapping.PROJECT_CONSTANT)) {
return StringUtil.escapeXml(path);
}
return FileUtil.toSystemDependentName(path);
}
};
StringBuilder description = new StringBuilder();
if (!invalidRoots.isEmpty()) {
if (invalidRoots.size() == 1) {
description.append("The directory " + rootToString.fun(invalidRoots.iterator().next()) + " is registered as a Git root, " +
"but it is not.");
description.append("The directory " + rootToDisplayableString.fun(invalidRoots.iterator().next()) + " is registered as a Git root, " +
"but no Git repositories were found there.");
}
else {
description.append("The following directories are registered as Git roots, but they are not: <br/>" +
StringUtil.join(invalidRoots, rootToString, ", "));
StringUtil.join(invalidRoots, rootToDisplayableString, ", "));
}
description.append("<br/>");
}
if (!unregisteredRoots.isEmpty()) {
if (unregisteredRoots.size() == 1) {
description.append("The directory " + rootToString.fun(unregisteredRoots.iterator().next()) + " is under Git, " +
description.append("The directory " + rootToDisplayableString.fun(unregisteredRoots.iterator().next()) + " is under Git, " +
"but is not registered in the Settings.");
}
else {
description.append("The following directories are roots of Git repositories, but they are not registered in the Settings: <br/>" +
StringUtil.join(unregisteredRoots, rootToString, ", "));
StringUtil.join(unregisteredRoots, rootToDisplayableString, ", "));
}
description.append("<br/>");
}
@@ -145,10 +148,10 @@ public class GitRootProblemNotifier {
}
@NotNull
private static String makeTitle(@NotNull Collection<VirtualFile> unregisteredRoots, @NotNull Collection<VirtualFile> invalidRoots) {
private static String makeTitle(@NotNull Collection<String> unregisteredRoots, @NotNull Collection<String> invalidRoots) {
String title;
if (unregisteredRoots.isEmpty()) {
title = "Invalid Git " + pluralize("root", invalidRoots.size());
title = "Invalid Git root " + pluralize("mapping", invalidRoots.size());
}
else if (invalidRoots.isEmpty()) {
title = "Unregistered Git " + pluralize("root", unregisteredRoots.size()) + " detected";
@@ -160,21 +163,21 @@ public class GitRootProblemNotifier {
}
@NotNull
private static Collection<VirtualFile> getUnregisteredRoots(@NotNull Collection<VcsRootError> errors) {
private static Collection<String> getUnregisteredRoots(@NotNull Collection<VcsRootError> errors) {
return filterErrorsByType(errors, VcsRootError.Type.UNREGISTERED_ROOT);
}
@NotNull
private static Collection<VirtualFile> getInvalidRoots(@NotNull Collection<VcsRootError> errors) {
return filterErrorsByType(errors, VcsRootError.Type.EXTRA_ROOT);
private static Collection<String> getInvalidRoots(@NotNull Collection<VcsRootError> errors) {
return filterErrorsByType(errors, VcsRootError.Type.EXTRA_MAPPING);
}
@NotNull
private static Collection<VirtualFile> filterErrorsByType(@NotNull Collection<VcsRootError> errors, @NotNull VcsRootError.Type type) {
Collection<VirtualFile> roots = new ArrayList<VirtualFile>();
private static Collection<String> filterErrorsByType(@NotNull Collection<VcsRootError> errors, @NotNull VcsRootError.Type type) {
Collection<String> roots = new ArrayList<String>();
for (VcsRootError error : errors) {
if (error.getType() == type) {
roots.add(error.getRoot());
roots.add(error.getMapping());
}
}
return roots;
@@ -37,15 +37,15 @@ class AbstractGitRootTest {
* And creates an instance of the project.
* @param gitRoots path to actual .git roots, relative to the project dir.
*/
Project initProject(Collection<String> gitRoots, Collection<String> projectStructure, Collection<String> linkedRoots) {
Project initProject(Collection<String> gitRoots, Collection<String> projectStructure, Collection<String> contentRoots = []) {
String projectDir = createDirs(gitRoots)
Project project = [
getBaseDir: { new GitMockVirtualFile(projectDir) }
] as Project
createProjectStructure(project, projectStructure);
createProjectStructure(project, linkedRoots);
createProjectStructure(project, contentRoots);
linkedRoots.each { myPlatformFacade.myProjectRootManager.myContentRoots << GitMockVirtualFile.fromPath(it, project)}
contentRoots.each { myPlatformFacade.myProjectRootManager.myContentRoots << GitMockVirtualFile.fromPath(it, project)}
project
}
@@ -120,39 +120,39 @@ class GitRootDetectorTest extends AbstractGitRootTest {
@Test
void "linked source root alone should be detected"() {
doTest linked_roots: ["../linked_root"],
gits: ["../linked_root"],
expected: ["../linked_root"],
full: false,
below: false
doTest content_roots: ["../linked_root"],
gits: ["../linked_root"],
expected: ["../linked_root"],
full: false,
below: false
}
@Test
void "linked source root and project root should be detected"() {
doTest linked_roots: ["../linked_root"],
gits: [".", "../linked_root"],
expected: [".", "../linked_root"],
full: true,
below: false
doTest content_roots: ["../linked_root"],
gits: [".", "../linked_root"],
expected: [".", "../linked_root"],
full: true,
below: false
}
@Test
void "linked source below Git"() {
doTest linked_roots: ["../linked_root/src"],
gits: [".", "../linked_root"],
expected: [".", "../linked_root"],
full: true,
below: false
doTest content_roots: ["../linked_root/src"],
gits: [".", "../linked_root"],
expected: [".", "../linked_root"],
full: true,
below: false
}
@Test
// This is a test of performance optimization via limitation: don't scan deep though the whole VFS
void "don't scan deeper than 2 levels below a content root"() {
doTest linked_roots: ["content_root"],
gits: ["community", "content_root/lev1/lev2", "content_root2/lev1/lev2/lev3"],
expected: ["community", "content_root/lev1/lev2"],
full: false,
below: false
doTest content_roots: ["content_root"],
gits: ["community", "content_root/lev1/lev2", "content_root2/lev1/lev2/lev3"],
expected: ["community", "content_root/lev1/lev2"],
full: false,
below: false
}
/**
@@ -161,7 +161,7 @@ class GitRootDetectorTest extends AbstractGitRootTest {
* @param map
*/
private void doTest(Map map) {
myProject = initProject(map.gits, map.project, map.linked_roots)
myProject = initProject(map.gits, map.project, map.content_roots)
testInfo empty: map.expected.empty,
full : map.full,
roots: map.expected,
@@ -16,6 +16,8 @@
package git4idea.roots
import com.intellij.openapi.project.Project
import com.intellij.openapi.vcs.VcsDirectoryMapping
import com.intellij.openapi.vcs.VcsRootError
import git4idea.test.GitMockVcsManager
import git4idea.test.GitTestPlatformFacade
import org.junit.Before
@@ -23,8 +25,6 @@ import org.junit.Test
import static git4idea.test.GitGTestUtil.toAbsolute
import static junit.framework.Assert.assertEquals
import git4idea.test.GitMockVirtualFile
import com.intellij.openapi.vcs.VcsRootError
/**
*
@@ -32,6 +32,8 @@ import com.intellij.openapi.vcs.VcsRootError
*/
class GitRootErrorsFinderTest extends AbstractGitRootTest {
static final String PROJECT = VcsDirectoryMapping.PROJECT_CONSTANT
Project myProject
GitTestPlatformFacade myPlatformFacade
GitMockVcsManager myVcsManager
@@ -103,9 +105,66 @@ class GitRootErrorsFinderTest extends AbstractGitRootTest {
roots: [".", "contrib"],
errors: [unreg: ["..", "community"], extra: [".", "contrib"]]
}
@Test
void "Project root, no gits, then error about extra root"() {
doTest content_roots: ["."],
git: [],
roots: [PROJECT],
errors: [extra: [PROJECT]]
}
@Test
void "Project root, full under git, then correct"() {
doTest content_roots: ["."],
git: ["."],
roots: [PROJECT],
errors: []
}
@Test
void "Project root, git for a content root below project, then correct"() {
doTest content_roots: [".", "content_root"],
git: [""],
roots: [PROJECT],
errors: []
}
@Test
void "Project root, git below project folder not in a content root, then unregistered root error"() {
// this is to be fixed: auto-detection of Git repositories in subfolders for the <Project> mapping
doTest content_roots: ["."],
git: ["community"],
roots: [PROJECT],
errors: [unreg: ["community"]]
}
@Test
void "Project root, git for full project, content root, linked source, folder below project, then error in folder below"() {
doTest content_roots: [".", "content_root", "../linked_source_root"],
git: [".", "content_root", "../linked_source_root", "folder"],
roots: [PROJECT],
errors: [unreg: ["folder"]]
}
@Test
void "Project root, root for folder, git for full project, content root, linked source, folder below project, then correct"() {
doTest content_roots: [".", "content_root", "../linked_source_root"],
git: [".", "content_root", "../linked_source_root", "folder"],
roots: [PROJECT, "folder"],
errors: []
}
@Test
void "Project root, git like in IDEA project, then correct"() {
doTest content_roots: [".", "community", "contrib"],
git: [".", "community", "contrib"],
roots: [PROJECT],
errors: []
}
private void doTest(Map map) {
myProject = initProject(map.git, [], [])
myProject = initProject(map.git, [], map.content_roots)
myVcsManager = (GitMockVcsManager) myPlatformFacade.getVcsManager(myProject)
addVcsRoots(map.roots)
@@ -120,17 +179,22 @@ class GitRootErrorsFinderTest extends AbstractGitRootTest {
void addVcsRoots(Collection<String> relativeRoots) {
relativeRoots.each {
String root = toAbsolute(it, myProject)
myVcsManager.addRoots(root)
if (it.equals(PROJECT)) {
myVcsManager.setProjectRootMapping()
}
else {
String root = toAbsolute(it, myProject)
myVcsManager.addRoots(root)
}
}
}
VcsRootError unreg(String path) {
return new VcsRootError(VcsRootError.Type.UNREGISTERED_ROOT, new GitMockVirtualFile(toAbsolute(path, myProject)))
return new VcsRootError(VcsRootError.Type.UNREGISTERED_ROOT, toAbsolute(path, myProject))
}
VcsRootError extra(String path) {
return new VcsRootError(VcsRootError.Type.EXTRA_ROOT, new GitMockVirtualFile(toAbsolute(path, myProject)))
return new VcsRootError(VcsRootError.Type.EXTRA_MAPPING, path.equals(PROJECT) ? PROJECT : toAbsolute(path, myProject))
}
@@ -16,6 +16,7 @@
package git4idea.test
import com.intellij.openapi.editor.markup.TextAttributes
import com.intellij.openapi.project.Project
import com.intellij.openapi.vcs.history.VcsHistoryCache
import com.intellij.openapi.vcs.impl.ContentRevisionCache
import com.intellij.openapi.vcs.impl.VcsDescriptor
@@ -24,6 +25,7 @@ import com.intellij.openapi.vcs.update.UpdatedFiles
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.PairProcessor
import com.intellij.util.Processor
import git4idea.PlatformFacade
import com.intellij.openapi.vcs.*
/**
@@ -32,20 +34,38 @@ import com.intellij.openapi.vcs.*
*/
public class GitMockVcsManager extends ProjectLevelVcsManager {
Project myProject
PlatformFacade myPlatformFacade
Collection<String> myRoots = []
boolean myProjectRootMapping = false
GitMockVcsManager(Project project, PlatformFacade facade) {
myProject = project
myPlatformFacade = facade
}
void addRoots(String... roots) {
roots.each { myRoots << it }
}
void setProjectRootMapping() {
myProjectRootMapping = true
}
@Override
VirtualFile[] getRootsUnderVcs(AbstractVcs vcs) {
myRoots.collect { new GitMockVirtualFile(it) }
List<VirtualFile> roots = myRoots.collect { new GitMockVirtualFile(it) }
roots.addAll(myPlatformFacade.getProjectRootManager(myProject).getContentRoots())
roots
}
@Override
List<VcsDirectoryMapping> getDirectoryMappings() {
myRoots.collect { new VcsDirectoryMapping(it, "Git") }
List<VcsDirectoryMapping> roots = myRoots.collect { new VcsDirectoryMapping(it, "Git") }
if (myProjectRootMapping) {
roots << new VcsDirectoryMapping("", "Git")
}
roots
}
@Override
@@ -38,7 +38,6 @@ public class GitTestPlatformFacade implements PlatformFacade {
GitMockProjectRootManager myProjectRootManager
public GitTestPlatformFacade() {
myVcsManager = new GitMockVcsManager()
myTestDialogManager = new TestDialogManager()
myProjectRootManager = new GitMockProjectRootManager()
}
@@ -46,6 +45,9 @@ public class GitTestPlatformFacade implements PlatformFacade {
@NotNull
@Override
ProjectLevelVcsManager getVcsManager(@NotNull Project project) {
if (!myVcsManager) {
myVcsManager = new GitMockVcsManager(project, this)
}
return myVcsManager
}