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

Fix #499 by prioritizing trigger phrase over retest phrase #757

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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