Skip to content
Permalink
Browse files
458: Push notification email not sent when new tags are pushed
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Aug 4, 2020
1 parent 9a38809 commit 5bf7aac5f37e79987446421fd67576514429923f
Showing 3 changed files with 19 additions and 7 deletions.
@@ -265,7 +265,7 @@ public Collection<WorkItem> run(Path scratchPath) {
.stream()
.filter(ref -> branches.matcher(ref.name()).matches())
.collect(Collectors.toList());
localRepo.fetchAll(false);
localRepo.fetchAll(true);

var history = UpdateHistory.create(tagStorageBuilder, historyPath.resolve("tags"), branchStorageBuilder, historyPath.resolve("branches"));
var errors = new ArrayList<Throwable>();
@@ -619,7 +619,8 @@ void testMailingListPROnce(TestInfo testInfo) throws IOException {
void testMailinglistTag(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo);
var tempFolder = new TemporaryDirectory();
var listServer = new TestMailmanServer()) {
var listServer = new TestMailmanServer();
var scratchFolder = new TemporaryDirectory()) {
var repo = credentials.getHostedRepository();
var localRepoFolder = tempFolder.path().resolve("repo");
var localRepo = CheckableRepository.init(localRepoFolder, repo.repositoryType());
@@ -665,7 +666,7 @@ void testMailinglistTag(TestInfo testInfo) throws IOException {
noTagsUpdater.attachTo(notifyBot);

// No mail should be sent on the first run as there is no history
TestBotRunner.runPeriodicItems(notifyBot);
TestBotRunner.runPeriodicItems(notifyBot, scratchFolder.path());
assertThrows(RuntimeException.class, () -> listServer.processIncoming(Duration.ofMillis(1)));

var editHash = CheckableRepository.appendAndCommit(localRepo, "Another line", "23456789: More fixes");
@@ -680,7 +681,7 @@ void testMailinglistTag(TestInfo testInfo) throws IOException {
localRepo.tag(editHash3, "jdk-13+0", "Added tag 4", "Duke Tagger", "tagger@openjdk.java.net");
localRepo.pushAll(repo.url());

TestBotRunner.runPeriodicItems(notifyBot);
TestBotRunner.runPeriodicItems(notifyBot, scratchFolder.path());
listServer.processIncoming();
listServer.processIncoming();
listServer.processIncoming();
@@ -25,6 +25,7 @@
import org.openjdk.skara.bot.*;

import java.io.IOException;
import java.nio.file.Path;
import java.util.*;

public class TestBotRunner {
@@ -38,11 +39,21 @@ public static void runPeriodicItems(Bot bot) throws IOException {
}

public static void runPeriodicItems(Bot bot, AfterItemHook afterItemHook) throws IOException {
try (var scratchFolder = new TemporaryDirectory()) {
runPeriodicItems(bot, afterItemHook, scratchFolder.path());
}
}

public static void runPeriodicItems(Bot bot, Path scratchFolder) throws IOException {
runPeriodicItems(bot, item -> {}, scratchFolder);
}

public static void runPeriodicItems(Bot bot, AfterItemHook afterItemHook, Path scratchFolder) throws IOException {
var items = new LinkedList<>(bot.getPeriodicItems());
for (var item = items.pollFirst(); item != null; item = items.pollFirst()) {
Collection<WorkItem> followUpItems = null;
try (var scratchFolder = new TemporaryDirectory()) {
followUpItems = item.run(scratchFolder.path());
Collection<WorkItem> followUpItems;
try {
followUpItems = item.run(scratchFolder);
afterItemHook.run(item);
} catch (RuntimeException e) {
item.handleRuntimeException(e);

1 comment on commit 5bf7aac

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 5bf7aac Aug 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.