Skip to content

Commit

Permalink
Fix #499 by prioritizing trigger phrase over retest phrase
Browse files Browse the repository at this point in the history
  • Loading branch information
mabrowning committed Oct 18, 2019
1 parent f4eb4bc commit 6ae51f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/main/java/org/jenkinsci/plugins/ghprb/GhprbPullRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -607,16 +607,11 @@ private void checkComment(GHIssueComment comment) throws IOException {
} else if (helper.isOktotestPhrase(body) && helper.isAdmin(sender)) { // ok to test
LOGGER.log(Level.FINEST, "Admin {0} gave OK to test", sender);
setAccepted(true);
} else if (helper.isRetestPhrase(body)) { // test this please
LOGGER.log(Level.FINEST, "Retest phrase");
if (helper.isAdmin(sender)) {
LOGGER.log(Level.FINEST, "Admin {0} gave retest phrase", sender);
shouldRun = true;
} else if (accepted && helper.isWhitelisted(sender)) {
LOGGER.log(Level.FINEST, "Retest accepted and user {0} is whitelisted", sender);
shouldRun = true;
}
} else if (helper.isTriggerPhrase(body)) { // trigger phrase
// The trigger phrase is prioritized over retest phrase because it
// encomposes the logic of retestPhrase (shouldRun = true), but also
// sets the triggered flag, which is important when the job is
// configured to "Only use trigger phrase for build triggering"
LOGGER.log(Level.FINEST, "Trigger phrase");
if (helper.isAdmin(sender)) {
LOGGER.log(Level.FINEST, "Admin {0} ran trigger phrase", sender);
Expand All @@ -627,6 +622,15 @@ private void checkComment(GHIssueComment comment) throws IOException {
shouldRun = true;
triggered = true;
}
} else if (helper.isRetestPhrase(body)) { // test this please
LOGGER.log(Level.FINEST, "Retest phrase");
if (helper.isAdmin(sender)) {
LOGGER.log(Level.FINEST, "Admin {0} gave retest phrase", sender);
shouldRun = true;
} else if (accepted && helper.isWhitelisted(sender)) {
LOGGER.log(Level.FINEST, "Retest accepted and user {0} is whitelisted", sender);
shouldRun = true;
}
}

if (shouldRun) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ public void testCheckMethodWhenPrWasUpdatedWithRetestPhrase() throws Exception {

verify(helper).isWhitelistPhrase(eq("test this please"));
verify(helper).isOktotestPhrase(eq("test this please"));
verify(helper).isTriggerPhrase(eq("test this please"));
verify(helper).isRetestPhrase(eq("test this please"));
verify(helper).isAdmin(eq(ghUser));
verify(helper, times(4)).isProjectDisabled();
Expand Down

0 comments on commit 6ae51f9

Please sign in to comment.