예제 #1
0
  void onPullRequestHook(PullRequest pr) throws IOException {

    ConcurrentMap<Integer, GhprbPullRequest> pulls = helper.getTrigger().getPulls();

    if ("closed".equals(pr.getAction())) {
      pulls.remove(pr.getNumber());
    } else if (helper.isProjectDisabled()) {
      logger.log(Level.FINE, "Not processing Pull request since the build is disabled");
    } else if ("opened".equals(pr.getAction()) || "reopened".equals(pr.getAction())) {
      GhprbPullRequest pull = pulls.get(pr.getNumber());
      if (pull == null) {
        pulls.putIfAbsent(pr.getNumber(), new GhprbPullRequest(pr.getPullRequest(), helper, this));
        pull = pulls.get(pr.getNumber());
      }
      pull.check(pr.getPullRequest());
    } else if ("synchronize".equals(pr.getAction())) {
      GhprbPullRequest pull = pulls.get(pr.getNumber());
      if (pull == null) {
        pulls.putIfAbsent(pr.getNumber(), new GhprbPullRequest(pr.getPullRequest(), helper, this));
        pull = pulls.get(pr.getNumber());
      }
      if (pull == null) {
        logger.log(Level.SEVERE, "Pull Request #{0} doesn''t exist", pr.getNumber());
        return;
      }
      pull.check(pr.getPullRequest());
    } else {
      logger.log(Level.WARNING, "Unknown Pull Request hook action: {0}", pr.getAction());
    }
    GhprbTrigger.getDscp().save();
  }
예제 #2
0
  void onIssueCommentHook(IssueComment issueComment) throws IOException {
    if (helper.isProjectDisabled()) {
      logger.log(Level.FINE, "Not checking comments since build is disabled");
      return;
    }
    int id = issueComment.getIssue().getNumber();
    logger.log(
        Level.FINER,
        "Comment on issue #{0} from {1}: {2}",
        new Object[] {
          id, issueComment.getComment().getUser(), issueComment.getComment().getBody()
        });
    if (!"created".equals(issueComment.getAction())) {
      return;
    }

    ConcurrentMap<Integer, GhprbPullRequest> pulls = helper.getTrigger().getPulls();

    GhprbPullRequest pull = pulls.get(id);
    if (pull == null) {
      pull = new GhprbPullRequest(getGitHubRepo().getPullRequest(id), helper, this);
      pulls.put(id, pull);
    }
    pull.check(issueComment.getComment());
    GhprbTrigger.getDscp().save();
  }
예제 #3
0
  private void check(GHPullRequest pr) throws IOException {
    ConcurrentMap<Integer, GhprbPullRequest> pulls = helper.getTrigger().getPulls();

    final Integer id = pr.getNumber();
    GhprbPullRequest pull;
    if (pulls.containsKey(id)) {
      pull = pulls.get(id);
    } else {
      pulls.putIfAbsent(id, new GhprbPullRequest(pr, helper, this));
      pull = pulls.get(id);
    }
    pull.check(pr);
  }