Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

244: Legacy reviewers jcheck configuration does not reset default #378

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -86,6 +86,13 @@ static ReviewersConfiguration parse(Section s) {
var contributors = s.get("contributors", DEFAULT.contributors());

if (s.contains("minimum")) {
// Reset defaults to 0
lead = 0;
reviewers = 0;
committers = 0;
authors = 0;
contributors = 0;

var minimum = s.get("minimum").asInt();
if (s.contains("role")) {
var role = s.get("role").asString();
@@ -383,4 +383,36 @@ void legacyConfigurationShouldAcceptRole() throws IOException {
assertEquals(Severity.ERROR, issue.severity());
assertEquals(check, issue.check());
}

@Test
void legacyConfigurationShouldAcceptCommitterRole() throws IOException {
var commit = commit(List.of("foo"));
var check = new ReviewersCheck(census(), utils);
var legacyConf = new ArrayList<>(CONFIGURATION);
legacyConf.add("minimum = 1");
legacyConf.add("role = committer");

var issues = toList(check.check(commit, message(commit), JCheckConfiguration.parse(legacyConf)));
assertEquals(0, issues.size());

commit = commit(List.of("bar"));
issues = toList(check.check(commit, message(commit), JCheckConfiguration.parse(legacyConf)));
assertEquals(0, issues.size());

commit = commit(List.of("baz"));
issues = toList(check.check(commit, message(commit), JCheckConfiguration.parse(legacyConf)));
assertEquals(0, issues.size());

commit = commit(List.of("qux"));
issues = toList(check.check(commit, message(commit), JCheckConfiguration.parse(legacyConf)));
assertEquals(1, issues.size());
assertTrue(issues.get(0) instanceof TooFewReviewersIssue);
var issue = (TooFewReviewersIssue) issues.get(0);
assertEquals(0, issue.numActual());
assertEquals(1, issue.numRequired());
assertEquals("committer", issue.role());
assertEquals(commit, issue.commit());
assertEquals(Severity.ERROR, issue.severity());
assertEquals(check, issue.check());
}
}