Search in sources :

Example 1 with MultiRootMessage

use of com.intellij.dvcs.MultiRootMessage in project intellij-community by JetBrains.

the class GitFetcher method fetchRootsAndNotify.

/**
   * Fetches all specified roots.
   * Once a root has failed, stops and displays the notification.
   * If needed, displays the successful notification at the end.
   * @param roots                   roots to fetch.
   * @param errorNotificationTitle  if specified, this notification title will be used instead of the standard "Fetch failed".
   *                                Use this when fetch is a part of a compound process.
   * @param notifySuccess           if set to {@code true} successful notification will be displayed.
   * @return true if all fetches were successful, false if at least one fetch failed.
   */
public boolean fetchRootsAndNotify(@NotNull Collection<GitRepository> roots, @Nullable String errorNotificationTitle, boolean notifySuccess) {
    MultiRootMessage additionalInfo = new MultiRootMessage(myProject, GitUtil.getRootsFromRepositories(roots), true);
    for (GitRepository repository : roots) {
        LOG.info("fetching " + repository);
        GitFetchResult result = fetch(repository);
        String ai = result.getAdditionalInfo();
        if (!StringUtil.isEmptyOrSpaces(ai)) {
            additionalInfo.append(repository.getRoot(), ai);
        }
        if (!result.isSuccess()) {
            Collection<Exception> errors = new ArrayList<>(getErrors());
            errors.addAll(result.getErrors());
            displayFetchResult(myProject, result, errorNotificationTitle, errors);
            return false;
        }
    }
    if (notifySuccess) {
        VcsNotifier.getInstance(myProject).notifySuccess("Fetched successfully");
    }
    if (!additionalInfo.asString().isEmpty()) {
        VcsNotifier.getInstance(myProject).notifyMinorInfo("Fetch details", additionalInfo.asString());
    }
    return true;
}
Also used : GitRepository(git4idea.repo.GitRepository) ArrayList(java.util.ArrayList) MultiRootMessage(com.intellij.dvcs.MultiRootMessage)

Aggregations

MultiRootMessage (com.intellij.dvcs.MultiRootMessage)1 GitRepository (git4idea.repo.GitRepository)1 ArrayList (java.util.ArrayList)1