Skip to content

Commit

Permalink
added check to not label/comment if users not linked accounts - would…
Browse files Browse the repository at this point in the history
… spam the PR
  • Loading branch information
garethahealy committed Dec 16, 2024
1 parent 9bc0d86 commit a466916
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.garethahealy</groupId>
<artifactId>github-stats</artifactId>
<version>2.2.2-SNAPSHOT</version>
<version>2.2.2</version>
<properties>
<compiler-plugin.version>3.13.0</compiler-plugin.version>
<maven.compiler.release>21</maven.compiler.release>
Expand Down
2 changes: 1 addition & 1 deletion src/main/docker/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v2.2.2-SNAPSHOT"
"version": "v2.2.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class LabelPullRequestForNewMembersService {
private final GitHubService gitHubService;
private final ConfigYamlMemberInRedHatLdapService configYamlMemberInRedHatLdapService;
private final Set<String> ignoreLabelKeys = new HashSet<>(List.of("merge-ok/user-in-ldap", "merge-ok/requires-manual-ldap"));
private final Set<String> cantFindUserLabelKeys = new HashSet<>(List.of("dont-merge/cant-find-user-in-ldap"));

@Inject
public LabelPullRequestForNewMembersService(GitHubService gitHubService, ConfigYamlMemberInRedHatLdapService configYamlMemberInRedHatLdapService) {
Expand Down Expand Up @@ -152,20 +153,25 @@ private void labelPullRequests(Map<GHPullRequest, List<WhoAreYou>> filteredPullR
logger.infof("Labeled (merge-ok/user-in-ldap) and commented: %s", pullRequest.getNumber());
}
} else {
Map<String, Object> root = new HashMap<>();
root.put("users", unknownMembers);
Optional<GHLabel> 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<String, Object> 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());
}
}
}
}
Expand Down

0 comments on commit a466916

Please sign in to comment.