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

940: Exception during item execution: has integrated label but no integration comment #1100

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
@@ -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());