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

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

chipx86
Review Board
master
f6796df...
reviewboard

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::?

daviddavid

How about "another extension's :py:meth:`is_approved` method" instead of "the previously ran hook".

daviddavid

I can see it being very useful to want to know why a review request is not approved. Can we ...

daviddavid

I think this should check the 'result' is a boolean, and have it throw ValueError if it's neither a tuple ...

daviddavid
david
  1. 
      
  2. I can see it being very useful to want to know why a review request is not approved. Can we work that in somehow?

    1. Yeah, I think that would be useful. Trying to figure out how best to model that, though. Could do a similar thing with the approval flag, where the previous value is passed in, but there's a risk of multiple hooks providing the same lists of errors.

  3. 
      
chipx86
david
  1. 
      
  2. How about "another extension's :py:meth:`is_approved` method" instead of "the previously ran hook".

  3. reviewboard/reviews/models/review_request.py (Diff revisions 1 - 2)
     
     
     

    I think this should check the 'result' is a boolean, and have it throw ValueError if it's neither a tuple or bool.

  4. 
      
chipx86
david
  1. Ship It!

  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Loading...