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(); }
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(); }
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); }
public void init() { // make the initial check call to populate our data structures if (!initGhRepository()) { // We could have hit the rate limit while initializing. If we // continue, then we will loop back around and attempt to re-init. return; } for (Entry<Integer, GhprbPullRequest> next : helper.getTrigger().getPulls().entrySet()) { GhprbPullRequest pull = next.getValue(); try { pull.init(helper, this); } catch (IOException e) { logger.log( Level.SEVERE, "Unable to initialize pull request #{0} for repo {1}, job {2}", new Object[] { next.getKey(), reponame, helper.getTrigger().getActualProject().getFullName() }); e.printStackTrace(); } } }