Repository (@NotNull Project project, @NotNull DataContext dataContext) { VcsRepositoryManager manager = VcsRepositoryManager.getInstance(project); VirtualFile file = dataContext.getData(CommonDataKeys.VIRTUAL_FILE); Repository repository = manager.getRepositoryForRootQuick(findVcsRootFor(project, file)); if (repository != null) return repository; VirtualFile selectedFile = getSelectedFile(dataContext); repository = manager.getRepositoryForRootQuick(findVcsRootFor(project, selectedFile)); if (repository != null) return repository; return null; }