From 373a6b8fef4853bda73c403ec18fa12d8fa53412 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 19 Aug 2024 17:24:51 +0100 Subject: [PATCH] Fix compile issue --- .../plugins/ghprb/GhprbRootAction.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRootAction.java b/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRootAction.java index 66b5c22..3957095 100644 --- a/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRootAction.java +++ b/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRootAction.java @@ -137,14 +137,16 @@ private void handleAction(String event, try { GitHub gh = GitHub.connectAnonymously(); - if (state == GHIssueState.CLOSED) { - LOGGER.log(Level.INFO, "Skip ''{0}'' event on closed PR", event); - return; - } else if (StringUtils.equalsIgnoreCase("issue_comment", event)) { + if (StringUtils.equalsIgnoreCase("issue_comment", event)) { comment = getIssueComment(payload, gh); GHIssueState state = comment.getIssue().getState(); + if (state == GHIssueState.CLOSED) { + LOGGER.log(Level.INFO, "Skip comment on closed PR"); + return; + } + if (!comment.getIssue().isPullRequest()) { LOGGER.log(Level.INFO, "Skip comment on Issue"); return; @@ -159,6 +161,13 @@ private void handleAction(String event, } else if (StringUtils.equalsIgnoreCase("pull_request", event)) { pr = getPullRequest(payload, gh); + GHIssueState state = pr.getPullRequest().getState(); + + if (state == GHIssueState.CLOSED) { + LOGGER.log(Level.INFO, "Skip ''{0}'' event on closed PR", event); + return; + } + repoName = pr.getRepository().getFullName(); LOGGER.log(Level.INFO, "Checking PR #{1} for {0}", new Object[] {repoName, pr.getNumber()});