Add an extensible API-level concept of "approval" to review requests.
Review Request #5414 — Created Feb. 6, 2014 and submitted
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.
Description | From | Last Updated |
---|---|---|
Can we use .. note::? |
david | |
How about "another extension's :py:meth:`is_approved` method" instead of "the previously ran hook". |
david | |
I can see it being very useful to want to know why a review request is not approved. Can we … |
david | |
I think this should check the 'result' is a boolean, and have it throw ValueError if it's neither a tuple … |
david |
- Change Summary:
-
Added support for approval failure reasons.
- Testing Done:
-
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 oftrue
.~ Only the latter had an
approved
value oftrue
, 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 anapproved
oftrue
on all three review~ requests. ~ requests, and an approval_failure
ofnull
.Changed the hook to return
false
, and saw anapproved
offalse
on all~ three. ~ three, with an approval failure. Changed the hook to return the previous approval, and saw the original results
on all three. - Commit:
-
24871b16024281585e5b89585251f6bfc894d8f0