Skip to content
Permalink
Browse files
jcheck: report all issues from "committer" check
Reviewed-by: rwestberg
  • Loading branch information
edvbld committed Mar 23, 2020
1 parent 8cbce58 commit 4e569e8a0c8cfe65806c200d454274b9b8c0958d
Showing 2 changed files with 16 additions and 11 deletions.
@@ -27,6 +27,7 @@
import org.openjdk.skara.vcs.Commit;
import org.openjdk.skara.vcs.openjdk.CommitMessage;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Logger;

@@ -58,6 +59,7 @@ private boolean hasRole(Project project, String role, String username, int versi

@Override
Iterator<Issue> check(Commit commit, CommitMessage message, JCheckConfiguration conf) {
var issues = new ArrayList<Issue>();
var project = census.project(conf.general().project());
var version = conf.census().version();
var domain = conf.census().domain();
@@ -67,23 +69,26 @@ Iterator<Issue> check(Commit commit, CommitMessage message, JCheckConfiguration
var committer = commit.committer();
if (committer.name() == null || committer.name().isEmpty()) {
log.finer("issue: committer.name is null or empty");
return iterator(new CommitterNameIssue(metadata));
issues.add(new CommitterNameIssue(metadata));
}
if (committer.email() == null || !committer.email().endsWith("@" + domain)) {
log.finer("issue: committer.email is null or does not end with @" + domain);
return iterator(new CommitterEmailIssue(domain, metadata));
issues.add(new CommitterEmailIssue(domain, metadata));
}

var username = committer.email().split("@")[0];
var allowedToMerge = conf.checks().committer().allowedToMerge();
if (!commit.isMerge() || !allowedToMerge.contains(username)) {
if (!hasRole(project, role, username, version)) {
log.finer("issue: committer does not have role " + role);
return iterator(new CommitterIssue(project, metadata));
if (committer.name() != null || committer.email() != null) {
var username = committer.email() == null ?
committer.name() : committer.email().split("@")[0];
var allowedToMerge = conf.checks().committer().allowedToMerge();
if (!commit.isMerge() || !allowedToMerge.contains(username)) {
if (!hasRole(project, role, username, version)) {
log.finer("issue: committer does not have role " + role);
issues.add(new CommitterIssue(project, metadata));
}
}
}

return iterator();
return issues.iterator();
}

@Override
@@ -210,7 +210,7 @@ void missingCommitterNameShouldFail() throws IOException {
var check = new CommitterCheck(census());
var issues = toList(check.check(commit, message, conf()));

assertEquals(1, issues.size());
assertEquals(2, issues.size());
assertTrue(issues.get(0) instanceof CommitterNameIssue);
var issue = (CommitterNameIssue) issues.get(0);
assertEquals(commit, issue.commit());
@@ -228,7 +228,7 @@ void missingCommitterEmailShouldFail() throws IOException {
var check = new CommitterCheck(census());
var issues = toList(check.check(commit, message, conf()));

assertEquals(1, issues.size());
assertEquals(2, issues.size());
assertTrue(issues.get(0) instanceof CommitterEmailIssue);
var issue = (CommitterEmailIssue) issues.get(0);
assertEquals(commit, issue.commit());

0 comments on commit 4e569e8

Please sign in to comment.