public static boolean isIgnored(File file, boolean checkSharability) { if (file == null) { return false; } File topFile = Git.getInstance().getTopmostManagedParent(file); // We assume that the toplevel directory should not be ignored. if (topFile == null || topFile.equals(file)) { return false; // We assume that the Project should not be ignored. } if (file.isDirectory()) { ProjectManager projectManager = ProjectManager.getDefault(); if (projectManager.isProject(FileUtil.toFileObject(file))) { return false; } } Repository repo = Git.getInstance().getRepository(topFile); ExcludeCache cache = getCache(repo); if (cache.isExcluded(file)) return true; if (file.getName().equals(".gitignore") || file.getName().equals(".gitattributes") || file.getName().equals(".gitmodules")) return false; if (checkSharability && !isSharable(file)) { return true; } return false; }
private static ExcludeCache getCache(Repository repo) { ExcludeCache cache = cacheMap.get(repo); if (cache == null) { cache = ExcludeCache.create(repo); cacheMap.put(repo, cache); } return cache; }