Skip to content

Commit

Permalink
fixing incorrect PR selection if its just deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
garethahealy committed Jan 6, 2025
1 parent 2b5ef84 commit 87a2374
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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> ignoreLabelKeys = new HashSet<>(List.of("merge-ok/user-in-ldap", "dont-merge/requires-manual-ldap"));
private final Set<String> cantFindUserLabelKeys = new HashSet<>(List.of("dont-merge/cant-find-user-in-ldap"));

@Inject
Expand Down Expand Up @@ -83,6 +83,7 @@ private Map<GHPullRequest, List<WhoAreYou>> filterPullRequests(GHRepository orgR
}
}

logger.info("--> Filter pull requests DONE");
return answer;
}

Expand Down Expand Up @@ -124,17 +125,21 @@ private void labelPullRequests(Map<GHPullRequest, List<WhoAreYou>> filteredPullR

// Something went wrong validating the config.yaml members
if (allMembers.isEmpty()) {
StringWriter stringWriter = new StringWriter();
requiresManualLdap.process(new HashMap<>(), stringWriter);

if (isDryRun) {
logger.warnf("DRY-RUN: Would have labeled 'dont-merge/requires-manual-ldap' pull request %s and added below comment", pullRequest.getNumber());
logger.warnf(stringWriter.toString());
if (pullRequest.getDeletions() > 0 && pullRequest.getAdditions() == 0) {
logger.warnf("%s PR only deleted. Think it is removing members, so ignoring.", pullRequest.getNumber());
} else {
pullRequest.addLabels("dont-merge/requires-manual-ldap");
pullRequest.comment(stringWriter.toString());
StringWriter stringWriter = new StringWriter();
requiresManualLdap.process(new HashMap<>(), stringWriter);

if (isDryRun) {
logger.warnf("DRY-RUN: Would have labeled 'dont-merge/requires-manual-ldap' pull request %s and added below comment", pullRequest.getNumber());
logger.warnf(stringWriter.toString());
} else {
pullRequest.addLabels("dont-merge/requires-manual-ldap");
pullRequest.comment(stringWriter.toString());

logger.infof("Labeled (dont-merge/requires-manual-ldap) and commented: %s", pullRequest.getNumber());
logger.infof("Labeled (dont-merge/requires-manual-ldap) and commented: %s", pullRequest.getNumber());
}
}
} else {
List<WhoAreYou> unknownMembers = allMembers.stream().filter(member -> member.name().isEmpty()).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If you are unsure how to set your GitHub ID within LDAP, see:

The below list of members have *${permissions}* and cannot be found using the above method.

Please add your GitHub handle to Rover.
Please add your GitHub handle to Rover:

<#list users as user>
- [ ] @${user.username()} - has *${permissions}* on ${user.repo()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ldapsearch -x -h ldap.corp.redhat.com -b dc=redhat,dc=com -s sub 'rhatSocialURL=
If you are unsure how to set your GitHub ID within LDAP, see:
- https://source.redhat.com/departments/it/it-information-security/wiki/details_about_rover_github_information_security_and_scanning

Please add your GitHub handle to Rover.
Please add your GitHub handle to Rover:

<#list users as user>
- [ ] @${user.username()}
Expand Down

0 comments on commit 87a2374

Please sign in to comment.