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

310: RFR thread integration messages should check target branch #512

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

Filter by extension

Filter by extension

Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -182,6 +182,11 @@ private List<Commit> filterAndSendPrCommits(HostedRepository repository, List<Co

var candidate = candidates.get(0);
var prLink = candidate.webUrl();
if (!candidate.targetRef().equals( {
log.warning("Pull request " + prLink + " targets " + candidate.targetRef() + " - commit is on " + branch.toString() + " - skipping");
var prLinkPattern = Pattern.compile("^(?:PR: )?" + Pattern.quote(prLink.toString()), Pattern.MULTILINE);

var rfrCandidates =
@@ -588,6 +588,92 @@ void testMailingListPROnly(TestInfo testInfo) throws IOException {

void testMailingListPROnlyMultipleBranches(TestInfo testInfo) throws IOException {
try (var listServer = new TestMailmanServer();
var credentials = new HostCredentials(testInfo);
var tempFolder = new TemporaryDirectory()) {
var repo = credentials.getHostedRepository();
var repoFolder = tempFolder.path().resolve("repo");
var localRepo = CheckableRepository.init(repoFolder, repo.repositoryType());
var masterHash = localRepo.resolve("master").orElseThrow();

var listAddress = EmailAddress.parse(listServer.createList("test"));
var mailmanServer = MailingListServerFactory.createMailmanServer(listServer.getArchive(), listServer.getSMTP(), Duration.ZERO);
var mailmanList = mailmanServer.getList(listAddress.address());
var tagStorage = createTagStorage(repo);
var branchStorage = createBranchStorage(repo);
var prIssuesStorage = createPullRequestIssuesStorage(repo);
var storageFolder = tempFolder.path().resolve("storage");

var sender = EmailAddress.from("duke", "duke@duke.duke");
var author = EmailAddress.from("author", "author@duke.duke");
var updater = MailingListUpdater.newBuilder()
var notifyBot = NotifyBot.newBuilder()

// Populate our known branches
localRepo.push(masterHash, repo.url(), "master", true);
localRepo.push(masterHash, repo.url(), "other", true);

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

localRepo.checkout(masterHash, true);
var editHash = CheckableRepository.appendAndCommit(localRepo, "Another line", "23456789: More fixes");
localRepo.push(editHash, repo.url(), "edit");
var pr = credentials.createPullRequest(repo, "master", "edit", "RFR: My PR");

// PR hasn't been integrated yet, so there should be no mail
assertThrows(RuntimeException.class, () -> listServer.processIncoming(Duration.ofMillis(1)));

// Simulate an RFR email
var rfr = Email.create(sender, "RFR: My PR", "PR: " + pr.webUrl().toString())

// And an integration (but it hasn't reached master just yet)
pr.addComment("Pushed as commit " + editHash.hex() + ".");

// Now push the same commit to another branch
localRepo.push(editHash, repo.url(), "other");

// This one should generate a plain integration mail
var conversations = mailmanList.conversations(Duration.ofDays(1));
assertEquals(2, conversations.size());
var secondEmail = conversations.get(0).first();
if (secondEmail.subject().contains("RFR")) {
secondEmail = conversations.get(1).first();
assertEquals("git: test: other: 23456789: More fixes", secondEmail.subject());

void testMailingListPR(TestInfo testInfo) throws IOException {
try (var listServer = new TestMailmanServer();