void (final @NotNull Project project, final @NotNull Git git, final Listener listener, final VirtualFile destinationParent, final String sourceRepositoryURL, final String directoryName, final String parentDirectory) { String projectAbsolutePath = Paths.get(parentDirectory, directoryName).toAbsolutePath().toString(); String projectPath = FileUtilRt.toSystemIndependentName(projectAbsolutePath); CloneTask cloneTask = new CloneTask() { @Override public @NotNull CloneTaskInfo taskInfo() { return new CloneTaskInfo(DvcsBundle.message("cloning.repository", sourceRepositoryURL), DvcsBundle.message("cloning.repository.cancel", sourceRepositoryURL), DvcsBundle.message("clone.repository"), DvcsBundle.message("clone.repository.tooltip"), DvcsBundle.message("clone.repository.failed"), DvcsBundle.message("clone.repository.canceled"), DvcsBundle.message("clone.stop.message.title"), DvcsBundle.message("clone.stop.message.description", sourceRepositoryURL)); } @Override public @NotNull CloneStatus run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(false); GitLineHandlerListener progressListener = GitStandardProgressAnalyzer.createListener(indicator); GitCommandResult result; try { result = git.clone(project, new File(parentDirectory), sourceRepositoryURL, directoryName, progressListener); } catch (Exception e) { if (listener instanceof GitCheckoutListener) { ((GitCheckoutListener) listener).checkoutFailed(null); } throw e; } if (result.success()) { File directory = new File(parentDirectory, directoryName); LOG.debug(String.format("Cloned into %s with success=%s", directory, result)); DvcsUtil.addMappingIfSubRoot(project, directory.getPath(), GitVcs.NAME); destinationParent.refresh(true, true); listener.directoryCheckedOut(directory, GitVcs.getKey()); listener.checkoutCompleted(); return CloneStatus.SUCCESS; } notifyError(project, result, sourceRepositoryURL); if (listener instanceof GitCheckoutListener) { ((GitCheckoutListener) listener).checkoutFailed(result); } return CloneStatus.FAILURE; } }; CloneableProjectsService.getInstance().runCloneTask(projectPath, cloneTask); }