From e4a9280a5a092cfe264dbbbbcb058a37ce684eb1 Mon Sep 17 00:00:00 2001 From: Rechi Date: Sat, 9 Jun 2018 21:00:00 +0200 Subject: [PATCH 1/2] move handled actions pull request hooks to a list --- .../java/org/jenkinsci/plugins/ghprb/GhprbRepository.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRepository.java b/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRepository.java index 1e1dba5dd..e762846ec 100644 --- a/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRepository.java +++ b/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRepository.java @@ -33,6 +33,7 @@ import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLEncoder; +import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; @@ -53,6 +54,8 @@ public class GhprbRepository implements Saveable { private static final transient EnumSet HOOK_EVENTS = EnumSet.of(GHEvent.ISSUE_COMMENT, GHEvent.PULL_REQUEST); + private static final List ALLOWED_ACTIONS = Arrays.asList("edited", "opened", "reopened", "synchronize"); + private static final transient boolean INSECURE_WEBHOOKS = SystemProperties.getBoolean( GhprbRepository.class.getName() + ".webhook.insecure", false); @@ -393,7 +396,7 @@ void onPullRequestHook(PullRequest pr) throws IOException { doSave = true; } else if (!trigger.isActive()) { LOGGER.log(Level.FINE, "Not processing Pull request since the build is disabled"); - } else if ("edited".equals(action) || "opened".equals(action) || "reopened".equals(action) || "synchronize".equals(action)) { + } else if (ALLOWED_ACTIONS.contains(action)) { GhprbPullRequest pull = getPullRequest(ghpr, number); pull.check(ghpr, true); doSave = true; From ca51d46d3033b9e214b5efc5961ded75af6bef0d Mon Sep 17 00:00:00 2001 From: Rechi Date: Sat, 9 Jun 2018 21:00:00 +0200 Subject: [PATCH 2/2] Handle (un)labeled pull request hooks --- src/main/java/org/jenkinsci/plugins/ghprb/GhprbRepository.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRepository.java b/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRepository.java index e762846ec..6a0820c67 100644 --- a/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRepository.java +++ b/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRepository.java @@ -54,7 +54,8 @@ public class GhprbRepository implements Saveable { private static final transient EnumSet HOOK_EVENTS = EnumSet.of(GHEvent.ISSUE_COMMENT, GHEvent.PULL_REQUEST); - private static final List ALLOWED_ACTIONS = Arrays.asList("edited", "opened", "reopened", "synchronize"); + private static final List ALLOWED_ACTIONS = Arrays.asList("edited", "labeled", "opened", "reopened", "synchronize", + "unlabeled"); private static final transient boolean INSECURE_WEBHOOKS = SystemProperties.getBoolean( GhprbRepository.class.getName() + ".webhook.insecure", false);