Skip to content
Permalink
Browse files
940: Exception during item execution: has integrated label but no int…
…egration comment

Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Mar 30, 2021
1 parent 2234a03 commit c33a832df2b6213dd0f37331792a20ef56f88176
@@ -83,6 +83,7 @@ public void onNewPullRequest(PullRequest pr) {
@Override
public void onStateChange(PullRequest pr, Issue.State oldState) {
if (pr.state() == Issue.State.CLOSED) {
PreIntegrations.retargetDependencies(pr);
deleteBranch(pr);
} else {
pushBranch(pr);
@@ -176,4 +176,51 @@ void branchMissing(TestInfo testInfo) throws IOException {
TestBotRunner.runPeriodicItems(notifyBot);
}
}

@Test
void retarget(TestInfo testInfo) throws IOException {
try (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());
credentials.commitLock(localRepo);
localRepo.pushAll(repo.url());

var storageFolder = tempFolder.path().resolve("storage");
var notifyBot = testBotBuilder(repo, storageFolder).create("notify", JSON.object());

// Initialize history
TestBotRunner.runPeriodicItems(notifyBot);

// Create a PR
var editHash = CheckableRepository.appendAndCommit(localRepo, "Another line");
localRepo.push(editHash, repo.url(), "source", true);
var pr = credentials.createPullRequest(repo, "master", "source", "This is a PR", false);
pr.addLabel("rfr");
TestBotRunner.runPeriodicItems(notifyBot);

// The target repo should now contain the new branch
var hash = localRepo.fetch(repo.url(), PreIntegrations.preIntegrateBranch(pr));
assertEquals(editHash, hash);

// Create follow-up work
var followUp = CheckableRepository.appendAndCommit(localRepo, "Follow-up work", "Follow-up change");
localRepo.push(followUp, repo.url(), "followup", true);
var followUpPr = credentials.createPullRequest(repo, PreIntegrations.preIntegrateBranch(pr), "followup", "This is another pull request");
assertEquals(PreIntegrations.preIntegrateBranch(pr), followUpPr.targetRef());

// Close the PR
pr.setState(Issue.State.CLOSED);
TestBotRunner.runPeriodicItems(notifyBot);

// The target repo should no longer contain the branch
assertThrows(IOException.class, () -> localRepo.fetch(repo.url(), PreIntegrations.preIntegrateBranch(pr)));

// The follow-up PR should have been retargeted
followUpPr = repo.pullRequest(followUpPr.id());
assertEquals("master", followUpPr.targetRef());
}
}
}
@@ -220,11 +220,6 @@ public void handle(PullRequestBot bot, PullRequest pr, CensusInstance censusInst
"The error has been logged and will be investigated. It is possible that this error " +
"is caused by a transient issue; feel free to retry the operation.");
}

// Additional cleanup outside of the integration lock
if (success) {
PreIntegrations.retargetDependencies(pr);
}
}

@Override
@@ -109,6 +109,9 @@ void integrateFollowup(TestInfo testInfo) throws IOException {
// The bot should reply with an ok message
assertLastCommentContains(pr, "Pushed as commit");

// The notifier will now retarget the follow up PR, simulate this
followUpPr.setTargetRef("master");

// The second should now become ready
TestBotRunner.runPeriodicItems(mergeBot);
followUpPr = author.pullRequest(followUpPr.id());

1 comment on commit c33a832

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on c33a832 Mar 30, 2021

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.