Skip to content
Closed
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
1 change: 1 addition & 0 deletions prow/ANNOUNCEMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## New features

New features added to each component:
- *August 27th, 2021* The prow `approve` plugin now accepts `/approved` as a synonym for `/approve`.
- *August 24, 2021* Postsubmit Prow jobs now support the `always_run` field.
This field interacts with the `run_if_changed` and `skip_if_only_changed`
fields as follows:
Expand Down
17 changes: 9 additions & 8 deletions prow/plugins/approve/approve.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ const (
// PluginName defines this plugin's registered name.
PluginName = "approve"

approveCommand = "APPROVE"
cancelArgument = "cancel"
lgtmCommand = "LGTM"
noIssueArgument = "no-issue"
removeApproveCommand = "REMOVE-APPROVE"
approveCommand = "APPROVE"
alternateApproveCommand = "APPROVED"
cancelArgument = "cancel"
lgtmCommand = "LGTM"
noIssueArgument = "no-issue"
removeApproveCommand = "REMOVE-APPROVE"
)

var (
Expand Down Expand Up @@ -530,7 +531,7 @@ func isApprovalCommand(isBot func(string) bool, lgtmActsAsApprove bool, c *comme

for _, match := range commandRegex.FindAllStringSubmatch(c.Body, -1) {
cmd := strings.ToUpper(match[1])
if (cmd == lgtmCommand && lgtmActsAsApprove) || cmd == approveCommand || cmd == removeApproveCommand {
if (cmd == lgtmCommand && lgtmActsAsApprove) || cmd == approveCommand || cmd == alternateApproveCommand || cmd == removeApproveCommand {
return true
}
}
Expand Down Expand Up @@ -606,7 +607,7 @@ func addApprovers(approversHandler *approvers.Approvers, approveComments []*comm
approversHandler.RemoveApprover(c.Author)
continue
}
if name != approveCommand && name != lgtmCommand {
if name != approveCommand && name != alternateApproveCommand && name != lgtmCommand {
continue
}
args := strings.ToLower(strings.TrimSpace(match[2]))
Expand All @@ -623,7 +624,7 @@ func addApprovers(approversHandler *approvers.Approvers, approveComments []*comm
)
}

if name == approveCommand {
if name == approveCommand || name == alternateApproveCommand {
approversHandler.AddApprover(
c.Author,
c.HTMLURL,
Expand Down
13 changes: 13 additions & 0 deletions prow/plugins/approve/approve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,19 @@ func TestHandleGenericComment(t *testing.T) {
lgtmActsAsApprove: true,
expectHandle: true,
},
{
name: "misspelled /approve as /approved, but whatever",
commentEvent: github.GenericCommentEvent{
Action: github.GenericCommentActionCreated,
IsPR: true,
Body: "/approved",
Number: 1,
User: github.User{
Login: "author",
},
},
expectHandle: true,
},
}

var handled bool
Expand Down