[vcs] IDEA-87769 Consider roots above the project dir as important ones

=> notify user if he has a Git repository above the project dir
(quite common invalid setup).
This commit is contained in:
Kirill Likhodedov
2014-11-11 17:02:58 +03:00
parent 1855f52de9
commit d98f87ae78
@@ -103,8 +103,11 @@ public class VcsRootProblemNotifier {
}
}
private boolean isUnderProjectDir(@NotNull String mapping) {
return mapping.equals(VcsDirectoryMapping.PROJECT_CONSTANT) || FileUtil.isAncestor(myProject.getBasePath(), mapping, false);
private boolean isUnderOrAboveProjectDir(@NotNull String mapping) {
String projectDir = myProject.getBasePath();
return mapping.equals(VcsDirectoryMapping.PROJECT_CONSTANT) ||
FileUtil.isAncestor(projectDir, mapping, false) ||
FileUtil.isAncestor(mapping, projectDir, false);
}
private boolean isIgnored(@NotNull String mapping) {
@@ -199,7 +202,7 @@ public class VcsRootProblemNotifier {
@Override
public boolean value(VcsRootError error) {
String mapping = error.getMapping();
return error.getType() == VcsRootError.Type.UNREGISTERED_ROOT && isUnderProjectDir(mapping) && !isIgnored(mapping);
return error.getType() == VcsRootError.Type.UNREGISTERED_ROOT && isUnderOrAboveProjectDir(mapping) && !isIgnored(mapping);
}
});
}