matthiasblaesing commented on pull request #21:
URL:
https://github.com/apache/netbeans-jenkins-lib/pull/21#issuecomment-702277325
The idea sounds sane to me. The ICLA Checker can be trivially ported to
groovy:
<details><summary>ICLA Checker</summary>
```groovy
class ICLAChecker {
private static final URL COMMITTER_SOURCE = new
URL("https://whimsy.apache.org/public/icla-info.json");
private static final URL NON_COMMITTER_SOURCE = new
URL("https://whimsy.apache.org/public/icla-info_noid.json");
private Set<String> committerSet = new HashSet<>();
private Set<String> nonCommitterSet = new HashSet<>();
public ICLAChecker() throws IOException {
init();
}
public boolean isSignee(String name) {
String normalizedName = normalize(name);
return committerSet.contains(normalizedName) ||
nonCommitterSet.contains(normalizedName);
}
private static String normalize(String input) {
return input
.toLowerCase(Locale.ROOT)
.replaceAll("\\s*", "");
}
private void init() throws IOException {
try {
def jsonSlurper = new JsonSlurper()
def committerData =
jsonSlurper.parse(ICLAChecker.COMMITTER_SOURCE)
committerSet = committerData["committers"]
.values()
.stream()
.map{v -> return normalize(v)}
.collect(Collectors.toUnmodifiableSet())
def nonCommitterData =
jsonSlurper.parse(ICLAChecker.NON_COMMITTER_SOURCE)
nonCommitterSet = nonCommitterData["non_committers"]
.stream()
.map{v -> return normalize(v)}
.collect(Collectors.toUnmodifiableSet())
} catch (MalformedURLException ex) {
throw new IOException(ex);
}
}
}
```
</details>
The styling of the message could IMHO improved, but a direct port of the
java variant should be doable.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists