From a4669164a02e91bcf0ab30351fffb5f472682810 Mon Sep 17 00:00:00 2001 From: Gareth Healy Date: Mon, 16 Dec 2024 20:05:14 +0000 Subject: [PATCH] added check to not label/comment if users not linked accounts - would spam the PR --- pom.xml | 2 +- src/main/docker/version.json | 2 +- .../LabelPullRequestForNewMembersService.java | 28 +++++++++++-------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 9e5c757..e88cd51 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.garethahealy github-stats - 2.2.2-SNAPSHOT + 2.2.2 3.13.0 21 diff --git a/src/main/docker/version.json b/src/main/docker/version.json index 0b38ea7..7250536 100644 --- a/src/main/docker/version.json +++ b/src/main/docker/version.json @@ -1,3 +1,3 @@ { - "version": "v2.2.2-SNAPSHOT" + "version": "v2.2.2" } \ No newline at end of file diff --git a/src/main/java/com/garethahealy/githubstats/services/users/LabelPullRequestForNewMembersService.java b/src/main/java/com/garethahealy/githubstats/services/users/LabelPullRequestForNewMembersService.java index 8e61827..b77ba0f 100644 --- a/src/main/java/com/garethahealy/githubstats/services/users/LabelPullRequestForNewMembersService.java +++ b/src/main/java/com/garethahealy/githubstats/services/users/LabelPullRequestForNewMembersService.java @@ -37,6 +37,7 @@ public class LabelPullRequestForNewMembersService { private final GitHubService gitHubService; private final ConfigYamlMemberInRedHatLdapService configYamlMemberInRedHatLdapService; private final Set ignoreLabelKeys = new HashSet<>(List.of("merge-ok/user-in-ldap", "merge-ok/requires-manual-ldap")); + private final Set cantFindUserLabelKeys = new HashSet<>(List.of("dont-merge/cant-find-user-in-ldap")); @Inject public LabelPullRequestForNewMembersService(GitHubService gitHubService, ConfigYamlMemberInRedHatLdapService configYamlMemberInRedHatLdapService) { @@ -152,20 +153,25 @@ private void labelPullRequests(Map> filteredPullR logger.infof("Labeled (merge-ok/user-in-ldap) and commented: %s", pullRequest.getNumber()); } } else { - Map root = new HashMap<>(); - root.put("users", unknownMembers); + Optional isLabeledCantFindUser = getLabel(pullRequest.getLabels(), cantFindUserLabelKeys); + if (isLabeledCantFindUser.isPresent()) { + logger.infof("%s has 'dont-merge/cant-find-user-in-ldap' so wont label/comment again, ignoring", pullRequest.getNumber()); + } else { + Map root = new HashMap<>(); + root.put("users", unknownMembers); - StringWriter stringWriter = new StringWriter(); - createWhoAreYouIssueRead.process(root, stringWriter); + StringWriter stringWriter = new StringWriter(); + createWhoAreYouIssueRead.process(root, stringWriter); - if (isDryRun) { - logger.warnf("DRY-RUN: Would have labeled 'dont-merge/cant-find-user-in-ldap' pull request %s and added below comment", pullRequest.getNumber()); - logger.warnf(stringWriter.toString()); - } else { - pullRequest.addLabels("dont-merge/cant-find-user-in-ldap"); - pullRequest.comment(stringWriter.toString()); + if (isDryRun) { + logger.warnf("DRY-RUN: Would have labeled 'dont-merge/cant-find-user-in-ldap' pull request %s and added below comment", pullRequest.getNumber()); + logger.warnf(stringWriter.toString()); + } else { + pullRequest.addLabels("dont-merge/cant-find-user-in-ldap"); + pullRequest.comment(stringWriter.toString()); - logger.infof("Labeled (dont-merge/cant-find-user-in-ldap) and commented: %s", pullRequest.getNumber()); + logger.infof("Labeled (dont-merge/cant-find-user-in-ldap) and commented: %s", pullRequest.getNumber()); + } } } }