Skip to content

Commit

Permalink
61: Remove sponsor label if PR is updated after flagged for integration
Browse files Browse the repository at this point in the history
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Aug 22, 2019
1 parent 3e24d9c commit 8467aae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bots/pr/src/main/java/org/openjdk/skara/bots/pr/CheckRun.java
Expand Up @@ -476,6 +476,16 @@ private void checkStatus() {
newLabels.remove("outdated");
}

// Ensure that the ready for sponsor label is up to date
newLabels.remove("sponsor");
var readyHash = ReadyForSponsorTracker.latestReadyForSponsor(pr.repository().host().getCurrentUserDetails(), comments);
if (readyHash.isPresent()) {
var acceptedHash = readyHash.get();
if (pr.getHeadHash().equals(acceptedHash)) {
newLabels.add("sponsor");
}
}

// Calculate current metadata to avoid unnecessary future checks
var metadata = workItem.getMetadata(pr.getTitle(), updatedBody, pr.getComments(), activeReviews, newLabels, censusInstance, pr.getTargetHash());
checkBuilder.metadata(metadata);
Expand Down
Expand Up @@ -269,6 +269,7 @@ void sponsorAfterChanges(TestInfo testInfo) throws IOException {
.filter(comment -> comment.body().contains("at version " + editHash.hex()))
.count();
assertEquals(1, ready);
assertTrue(pr.getLabels().contains("sponsor"));

// Push another change
var updateHash = CheckableRepository.appendAndCommit(localRepo,"Yet more stuff");
Expand All @@ -284,6 +285,10 @@ void sponsorAfterChanges(TestInfo testInfo) throws IOException {
}
} while (pr.getHeadHash().equals(lastHeadHash));

// The label should have been dropped
TestBotRunner.runPeriodicItems(mergeBot);
assertFalse(pr.getLabels().contains("sponsor"));

// Reviewer now tries to sponsor
var reviewerPr = reviewer.getPullRequest(pr.getId());
reviewerPr.addComment("/sponsor");
Expand All @@ -302,6 +307,7 @@ void sponsorAfterChanges(TestInfo testInfo) throws IOException {
// It should now be possible to sponsor
reviewerPr.addComment("/sponsor");
TestBotRunner.runPeriodicItems(mergeBot);
assertTrue(pr.getLabels().contains("sponsor"));

// The bot should have pushed the commit
var pushed = pr.getComments().stream()
Expand Down

0 comments on commit 8467aae

Please sign in to comment.