Skip to content

Commit

Permalink
Add unique github id check
Browse files Browse the repository at this point in the history
Signed-off-by: Brandon Shien <[email protected]>
  • Loading branch information
bshien committed Nov 4, 2024
1 parent 91099eb commit dee9e74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.HashSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -237,6 +239,7 @@ public List<MaintainerData> repoMaintainers(String repo) {
String rawMaintainersFile = String.format("https://raw.githubusercontent.com/opensearch-project/%s/main/MAINTAINERS.md", repo);
boolean isEmeritusSection = false;
List<MaintainerData> maintainersList = new ArrayList<>();
Set<String> maintainerIdSet = new HashSet<>();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(rawMaintainersFile).openStream(),
StandardCharsets.UTF_8))) {
String line;
Expand All @@ -256,7 +259,10 @@ public List<MaintainerData> repoMaintainers(String repo) {
maintainerData.setName(maintainer);
maintainerData.setGithubLogin(githubId);
maintainerData.setAffiliation(affiliation);
maintainersList.add(maintainerData);
if(!maintainerIdSet.contains(githubId)){ // Add only unique github ids
maintainerIdSet.add(githubId);
maintainersList.add(maintainerData);
}
}
}
} else if (line.contains("Emeritus")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ public void testRepoMaintainers() {
String expectedContent = "test content\n" +
"| Maintainer | GitHub ID | Affiliation |\n" +
"| maintainer | [githubId](https://github.com/githubId) | affiliation |\n" +
"| maintainer | [githubId](https://github.com/githubId) | affiliation |\n" +
"## Emeritus Maintainers" +
"| maintainer | [githubId](https://github.com/githubId) | affiliation |\n" +
"line3\n";
Expand Down

0 comments on commit dee9e74

Please sign in to comment.