From a667f19408edd4d36f31fe2d5ca9df0edc6f7a85 Mon Sep 17 00:00:00 2001 From: Azmi TOUIL <42934070+AzmiTouil@users.noreply.github.com> Date: Thu, 14 Sep 2023 18:04:58 +0200 Subject: [PATCH] fix: Merger PR cancels gamification for user - MEED-2441 - Meeds-io/MIPs#64 (#99) Prior to this change, the PR merger was considered as closing a PR event and canceling a gamification --- .../gamification/github/plugin/PullRequestTriggerPlugin.java | 3 ++- .../java/org/exoplatform/gamification/github/utils/Utils.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gamification-github-services/src/main/java/org/exoplatform/gamification/github/plugin/PullRequestTriggerPlugin.java b/gamification-github-services/src/main/java/org/exoplatform/gamification/github/plugin/PullRequestTriggerPlugin.java index eabf3dc9..f16af449 100644 --- a/gamification-github-services/src/main/java/org/exoplatform/gamification/github/plugin/PullRequestTriggerPlugin.java +++ b/gamification-github-services/src/main/java/org/exoplatform/gamification/github/plugin/PullRequestTriggerPlugin.java @@ -32,7 +32,8 @@ public List getEvents(Map payload) { String objectId = extractSubItem(payload, PULL_REQUEST, HTML_URL); if (Objects.equals(extractSubItem(payload, ACTION), OPENED)) { return Collections.singletonList(new Event(CREATE_PULL_REQUEST_EVENT_NAME, null, userId, objectId, PR_TYPE)); - } else if (Objects.equals(extractSubItem(payload, ACTION), CLOSED)) { + } else if (Objects.equals(extractSubItem(payload, ACTION), CLOSED) + && !Boolean.parseBoolean(extractSubItem(payload, PULL_REQUEST, MERGED))) { return Collections.singletonList(new Event(CLOSE_PULL_REQUEST_EVENT_NAME, null, userId, objectId, PR_TYPE)); } else if (Objects.equals(extractSubItem(payload, ACTION), REVIEW_REQUESTED)) { String requestedReviewer = extractSubItem(payload, REQUESTED_REVIEWER, LOGIN); diff --git a/gamification-github-services/src/main/java/org/exoplatform/gamification/github/utils/Utils.java b/gamification-github-services/src/main/java/org/exoplatform/gamification/github/utils/Utils.java index b672b4cf..7dc7984c 100644 --- a/gamification-github-services/src/main/java/org/exoplatform/gamification/github/utils/Utils.java +++ b/gamification-github-services/src/main/java/org/exoplatform/gamification/github/utils/Utils.java @@ -97,6 +97,8 @@ public class Utils { public static final String UNLABELED = "unlabeled"; + public static final String MERGED = "merged"; + public static final String REVIEW_REQUESTED = "review_requested"; public static final String REVIEW_REQUEST_REMOVED = "review_request_removed";