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

843: Mails are not forwarded to a closed PR any more #1103

Closed
wants to merge 6 commits into from
Closed
Changes from 2 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
@@ -23,17 +23,17 @@
package org.openjdk.skara.bots.mlbridge;

import org.openjdk.skara.bot.WorkItem;
import org.openjdk.skara.mailinglist.MailingList;
import org.openjdk.skara.mailinglist.MailingListReader;

import java.nio.file.Path;
import java.time.Duration;
import java.util.*;

public class ArchiveReaderWorkItem implements WorkItem {
private final MailingListArchiveReaderBot bot;
private final MailingList list;
private final MailingListReader list;

ArchiveReaderWorkItem(MailingListArchiveReaderBot bot, MailingList list) {
ArchiveReaderWorkItem(MailingListArchiveReaderBot bot, MailingListReader list) {
this.bot = bot;
this.list = list;
}
@@ -171,7 +171,7 @@ private void updateWebrevComment(List<Comment> comments, int index, List<WebrevD
}
}

private List<Email> parseArchive(MailingList archive) {
private List<Email> parseArchive(MailingListReader archive) {
var conversations = archive.conversations(Duration.ofDays(365));

if (conversations.size() == 0) {
@@ -253,7 +253,7 @@ public Collection<WorkItem> run(Path scratchPath) {
var archiveRepo = materializeArchive(path);
var mboxBasePath = path.resolve(bot.codeRepo().name());
var mbox = MailingListServerFactory.createMboxFileServer(mboxBasePath);
var reviewArchiveList = mbox.getList(pr.id());
var reviewArchiveList = mbox.getListReader(pr.id());
var sentMails = parseArchive(reviewArchiveList);
var labels = new HashSet<>(pr.labelNames());

@@ -36,7 +36,7 @@

public class MailingListArchiveReaderBot implements Bot {
private final EmailAddress archivePoster;
private final MailingList list;
private final MailingListReader list;
private final Set<HostedRepository> repositories;
private final Map<EmailAddress, String> parsedConversations = new HashMap<>();
private final Map<EmailAddress, PullRequest> resolvedPullRequests = new HashMap<>();
@@ -45,7 +45,7 @@ public class MailingListArchiveReaderBot implements Bot {
private final Pattern pullRequestLinkPattern = Pattern.compile("^(?:PR: |Pull request:\\R)(.*?)$", Pattern.MULTILINE);
private final Logger log = Logger.getLogger("org.openjdk.skara.bots.mlbridge");

MailingListArchiveReaderBot(EmailAddress archivePoster, MailingList list, Set<HostedRepository> repositories) {
MailingListArchiveReaderBot(EmailAddress archivePoster, MailingListReader list, Set<HostedRepository> repositories) {
this.archivePoster = archivePoster;
this.list = list;
this.repositories = repositories;
@@ -88,7 +88,6 @@ public List<Bot> create(BotConfiguration configuration) {
var archiveRef = configuration.repositoryRef(specific.get("archive").asString());
var issueTracker = URIBuilder.base(specific.get("issues").asString()).build();

var listNamesForReading = new HashSet<EmailAddress>();
var allRepositories = new HashSet<HostedRepository>();

var readyLabels = specific.get("ready").get("labels").stream()
@@ -112,12 +111,17 @@ public List<Bot> create(BotConfiguration configuration) {
Map.of();

var lists = parseLists(repoConfig.get("lists"));
var listsForReading = listNamesForReading.stream()
.map(EmailAddress::localPart)
.collect(Collectors.toList());
var bot = new MailingListArchiveReaderBot(from, mailmanServer.getList(listsForReading.toArray(new String[0])), allRepositories);
ret.add(bot);

if (!repoConfig.contains("bidirectional") || repoConfig.get("bidirectional").asBoolean()) {
var listNamesForReading = new HashSet<EmailAddress>();
for (var list : lists) {
listNamesForReading.add(list.list());
}
var listsForReading = listNamesForReading.stream()
.map(EmailAddress::localPart)
.collect(Collectors.toList());
var bot = new MailingListArchiveReaderBot(from, mailmanServer.getListReader(listsForReading.toArray(new String[0])), allRepositories);
ret.add(bot);
}

var folder = repoConfig.contains("folder") ? repoConfig.get("folder").asString() : configuration.repositoryName(repo);

@@ -165,11 +169,6 @@ public List<Bot> create(BotConfiguration configuration) {
}
ret.add(botBuilder.build());

if (!repoConfig.contains("bidirectional") || repoConfig.get("bidirectional").asBoolean()) {
for (var list : lists) {
listNamesForReading.add(list.list());
}
}
allRepositories.add(configuration.repository(repo));
}

@@ -86,7 +86,7 @@ void simpleArchive(TestInfo testInfo) throws IOException {
// The mailing list as well
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(),
Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress.address());
var mailmanList = mailmanServer.getListReader(listAddress.address());
var readerBot = new MailingListArchiveReaderBot(from, mailmanList, Set.of(archive));

// Populate the projects repository
@@ -162,7 +162,7 @@ void rememberBridged(TestInfo testInfo) throws IOException {
// The mailing list as well
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(),
Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress.address());
var mailmanList = mailmanServer.getListReader(listAddress.address());
var readerBot = new MailingListArchiveReaderBot(from, mailmanList, Set.of(archive));

// Populate the projects repository
@@ -238,7 +238,7 @@ void largeEmail(TestInfo testInfo) throws IOException {
// The mailing list as well
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(),
Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress.address());
var mailmanList = mailmanServer.getListReader(listAddress.address());
var readerBot = new MailingListArchiveReaderBot(from, mailmanList, Set.of(archive));

// Populate the projects repository
@@ -215,7 +215,7 @@ void simpleArchive(TestInfo testInfo) throws IOException {
// The mailing list as well
listServer.processIncoming();
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(), Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress.address());
var mailmanList = mailmanServer.getListReader(listAddress.address());
var conversations = mailmanList.conversations(Duration.ofDays(1));
assertEquals(1, conversations.size());
var mail = conversations.get(0).first();
@@ -797,7 +797,7 @@ void reviewComment(TestInfo testInfo) throws IOException {

// The mailing list as well
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(), Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress.address());
var mailmanList = mailmanServer.getListReader(listAddress.address());
var conversations = mailmanList.conversations(Duration.ofDays(1));
assertEquals(1, conversations.size());
var mail = conversations.get(0).first();
@@ -885,7 +885,7 @@ void combineComments(TestInfo testInfo) throws IOException {

// As well as the mailing list
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(), Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress.address());
var mailmanList = mailmanServer.getListReader(listAddress.address());
var conversations = mailmanList.conversations(Duration.ofDays(1));
assertEquals(1, conversations.size());
var mail = conversations.get(0).first();
@@ -1002,7 +1002,7 @@ void commentThreading(TestInfo testInfo) throws IOException {

// Check the mailing list
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(), Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress.address());
var mailmanList = mailmanServer.getListReader(listAddress.address());
var conversations = mailmanList.conversations(Duration.ofDays(1));
assertEquals(1, conversations.size());
var mail = conversations.get(0).first();
@@ -1605,7 +1605,7 @@ void incrementalChanges(TestInfo testInfo) throws IOException {

// Check that sender address is set properly
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(), Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress.address());
var mailmanList = mailmanServer.getListReader(listAddress.address());
var conversations = mailmanList.conversations(Duration.ofDays(1));
assertEquals(1, conversations.size());
for (var newMail : conversations.get(0).allMessages()) {
@@ -1732,7 +1732,7 @@ void rebased(TestInfo testInfo) throws IOException {

// Check that sender address is set properly
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(), Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress.address());
var mailmanList = mailmanServer.getListReader(listAddress.address());
var conversations = mailmanList.conversations(Duration.ofDays(1));
assertEquals(1, conversations.size());
for (var newMail : conversations.get(0).allMessages()) {
@@ -2897,7 +2897,7 @@ void multipleRecipients(TestInfo testInfo) throws IOException {

// The mail should have been sent to list1
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(), Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress1.address());
var mailmanList = mailmanServer.getListReader(listAddress1.address());
var conversations = mailmanList.conversations(Duration.ofDays(1));
assertEquals(1, conversations.size());
var mail = conversations.get(0).first();
@@ -3029,7 +3029,7 @@ void jsonArchive(TestInfo testInfo) throws IOException {
// The mailing list as well
listServer.processIncoming();
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(), Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress.address());
var mailmanList = mailmanServer.getListReader(listAddress.address());
var conversations = mailmanList.conversations(Duration.ofDays(1));
assertEquals(1, conversations.size());
var mail = conversations.get(0).first();