Add an extensible API-level concept of "approval" to review requests.

Review Request #5414 — Created Feb. 6, 2014 and submitted — Latest diff uploaded

Review Board

Review request resources now have an approved boolean field that
indicates if the review request has met sufficient approval to pass
review and become part of the codebase. This is not exposed in the
Review Board UI, but extensions and consumers of the API can make use of
it for such things as preventing check-ins.

By default, this considers a review request to be approved if there's at
least one Ship It! and no open issues.

A new hook, ReviewRequestApprovalHook, can be used to alter the approval
logic by augmenting or replacing the existing approval code. This can be
used to easily require, for example, a minimum number of Ship It!'s, or
review by a member of a certain core group, or to provide different
logic depending on the department or repository.

Down the road, we can use this for the new pre-commit hooks, and we can
provide an extension utilizing this to make it easy to add some of the
more common types of approval logic people want.

Tested with the default logic, and inspected the API payload for review
requests with:

  • No Ship It
  • Ship It, with open issues
  • Ship It, without open issues

Only the latter had an approved value of true, and was the only one with
a null approval_failure.

Then I wrote a hook on an extension I use for my testing. I hard-coded a
result of true. I then saw an approved of true on all three review
requests, and an approval_failure of null.

Changed the hook to return false, and saw an approved of false on all
three, with an approval failure.

Changed the hook to return the previous approval, and saw the original results
on all three.