@Override protected void onSuccess() { result.set(GitFetchResult.success()); }
private boolean doFetchRemote(@NotNull BranchInfo branch) { if (branch.getName() == null) { return false; } GitFetchResult result = new GitFetcher(project, new EmptyProgressIndicator(), false).fetch(gitRepository.getRoot(), branch.getRemoteName(), null); if (!result.isSuccess()) { GitFetcher.displayFetchResult(project, result, null, result.getErrors()); return false; } return true; }
@Override protected void onCancel() { log.info("Cancelled fetch."); result.set(GitFetchResult.cancel()); }
private static boolean fetchGit( @NotNull final Project project, @NotNull ProgressIndicator indicator, @NotNull GitRepository repository, final @NotNull String remote) { GitFetcher fetcher = new GitFetcher(project, indicator, true); GitFetchResult result = fetcher.fetch(repository); if (!result.isSuccess()) { SwingUtilities.invokeLater( () -> { Notification notification = new Notification( NOTIFICATION_GROUP_ID, CloudReposMessageBundle.message("uploadtogcp.fetchfailedtitle"), CloudReposMessageBundle.message("uploadtogcp.fetchfailed", remote), NotificationType.ERROR); notification.notify(project); }); return false; } repository.update(); return true; }
@Override public void run(@NotNull ProgressIndicator indicator) { GitRemote remote; String fetch; String url; boolean commitIsFetched = checkIfCommitIsFetched(gitRepository, commitHash); if (commitIsFetched) { // 'git fetch' works with a local path instead of a remote -> this way FETCH_HEAD is set remote = new GitRemote(gitRepository.getRoot().getPath(), Collections.<String>emptyList(), Collections.<String>emptySet(), Collections.<String>emptyList(), Collections.<String>emptyList()); fetch = commitHash; url = ""; } else { remote = getRemoteForChange(project, gitRepository, fetchInfo).orNull(); if (remote == null) { return; } fetch = fetchInfo.ref; url = remote.getFirstUrl(); } GitFetchResult result = fetchNatively(gitRepository.getGitDir(), remote, url, fetch, project, indicator); if (!result.isSuccess()) { GitFetcher.displayFetchResult(project, result, null, result.getErrors()); } } });
@Override protected void onFailure() { log.warn("Error fetching: " + h.errors()); Collection<Exception> errors = Lists.newArrayList(); errors.addAll(h.errors()); result.set(GitFetchResult.error(errors)); } });