Skip to content
Permalink
Browse files

20: Do not send emails that a reviewer has added a comment

Reviewed-by: ehelin
  • Loading branch information
Robin Westberg
Robin Westberg committed Jul 1, 2019
1 parent c704f49 commit 2a1e24bdd9ecbc76378275db4a7372affa82e74a
@@ -765,6 +765,9 @@ void notifyReviewVerdicts(TestInfo testInfo) throws IOException {
// The archive should contain a note
Repository.materialize(archiveFolder.path(), archive.getUrl(), "master");
assertEquals(1, archiveContainsCount(archiveFolder.path(), "This PR has been reviewed.*more changes are needed"));
if (author.host().supportsReviewBody()) {
assertEquals(1, archiveContainsCount(archiveFolder.path(), "Reason 1"));
}

// Then approve it
reviewedPr.addReview(Review.Verdict.APPROVED, "Reason 2");
@@ -775,6 +778,9 @@ void notifyReviewVerdicts(TestInfo testInfo) throws IOException {
// The archive should contain another note
Repository.materialize(archiveFolder.path(), archive.getUrl(), "master");
assertEquals(1, archiveContainsCount(archiveFolder.path(), "This PR.*approved"));
if (author.host().supportsReviewBody()) {
assertEquals(1, archiveContainsCount(archiveFolder.path(), "Reason 2"));
}

// Yet another change
reviewedPr.addReview(Review.Verdict.DISAPPROVED, "Reason 3");
@@ -785,6 +791,9 @@ void notifyReviewVerdicts(TestInfo testInfo) throws IOException {
// The archive should contain another note
Repository.materialize(archiveFolder.path(), archive.getUrl(), "master");
assertEquals(2, archiveContainsCount(archiveFolder.path(), "This PR.*more changes"));
if (author.host().supportsReviewBody()) {
assertEquals(1, archiveContainsCount(archiveFolder.path(), "Reason 3"));
}
}
}
}
@@ -454,8 +454,10 @@ private void checkStatus() {
var statusMessage = getStatusMessage(activeReviews, visitor);
var updatedBody = updateStatusMessage(statusMessage);

// Post / update approval messages
updateReviewedMessages(comments, allReviews);
// Post / update approval messages (only needed if the review itself can't contain a body)
if (!pr.repository().host().supportsReviewBody()) {
updateReviewedMessages(comments, allReviews);
}

var commit = prInstance.localRepo().lookup(localHash).orElseThrow();
var commitMessage = String.join("\n", commit.message());
@@ -32,6 +32,7 @@
import java.util.Map;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

class CheckTests {
@Test
@@ -376,6 +377,9 @@ void individualReviewComments(TestInfo testInfo) throws IOException {
var author = credentials.getHostedRepository();
var reviewer = credentials.getHostedRepository();

// This test is only relevant on hosts not supporting proper review comment bodies
assumeTrue(!author.host().supportsReviewBody());

var censusBuilder = credentials.getCensusBuilder()
.addAuthor(author.host().getCurrentUserDetails().id())
.addReviewer(reviewer.host().getCurrentUserDetails().id());
@@ -425,7 +425,7 @@ public static void main(String[] args) throws IOException {
if (action.equals("integrate")) {
pr.addComment("/integrate");
} else if (action.equals("approve")) {
pr.addReview(Review.Verdict.APPROVED);
pr.addReview(Review.Verdict.APPROVED, "Looks good!");
} else {
throw new IllegalStateException("unexpected action: " + action);
}
@@ -29,6 +29,7 @@
HostedRepository getRepository(String name);
HostUserDetails getUserDetails(String username);
HostUserDetails getCurrentUserDetails();
boolean supportsReviewBody();

static Host from(URI uri, PersonalAccessToken pat) {
return HostFactory.createFromURI(uri, pat);
@@ -178,4 +178,9 @@ public HostUserDetails getCurrentUserDetails() {
}
return currentUser;
}

@Override
public boolean supportsReviewBody() {
return true;
}
}
@@ -115,6 +115,12 @@ public HostUserDetails getCurrentUserDetails() {
return parseUserDetails(details);
}

@Override
public boolean supportsReviewBody() {
// GitLab CE does not support this
return false;
}

boolean isProjectForkComplete(String name) {
var project = getProjectInfo(name);
if (project.contains("import_status")) {
@@ -105,6 +105,11 @@ public HostUserDetails getCurrentUserDetails() {
return data.users.get(currentUser);
}

@Override
public boolean supportsReviewBody() {
return true;
}

void close() {
if (currentUser == 0) {
data.folders.forEach(TemporaryDirectory::close);

0 comments on commit 2a1e24b

Please sign in to comment.
You can’t perform that action at this time.