private CommitStatus getCommitStatus()

in commit-status-publisher-server/src/main/java/jetbrains/buildServer/commitPublisher/github/GitHubPublisher.java [217:251]


  private CommitStatus getCommitStatus(@NotNull BuildRevision revision, @NotNull BuildPromotion buildPromotion) throws PublisherException {
    Map<String, String> params;
    try {
      params = getParams(buildPromotion);
    } catch (GitHubContextResolveException e) {
      return null;
    }
    ChangeStatusUpdater.Handler handler = myUpdater.getHandler(revision.getRoot(), params, this);

    if (!revision.getRoot().getVcsName().equals("jetbrains.git")) {
      LOG.warn("No revisions were found to request GitHub status. Please check you have Git VCS roots in the build configuration");
      return null;
    }

    final String context = params.get(Constants.GITHUB_CONTEXT);
    if (context == null) {
      return null;
    }

    AtomicReference<PublisherException> exception = new AtomicReference<>(null);

    CommitStatus statusFromCache = myStatusesCache.getStatusFromCache(revision, context, () -> {
      try {
        return handler.getStatuses(revision);
      } catch (PublisherException e) {
        exception.set(e);
      }
      return Collections.emptyList();
    }, status -> status.context);

    if (exception.get() != null) {
      throw exception.get();
    }
    return statusFromCache;
  }