diff options
author | Jonas Franz <info@jonasfranz.software> | 2018-12-11 12:28:37 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2018-12-11 19:28:37 +0800 |
commit | 9681c8373426e8364760f033b9935b81b9276351 (patch) | |
tree | d9308c33809fdfa7859fd9a1057432a74a28c92f /models/review.go | |
parent | 64680b72bd1b0a0fc164296ff0cc7319ae7dc4ca (diff) | |
download | gitea-9681c8373426e8364760f033b9935b81b9276351.tar.gz gitea-9681c8373426e8364760f033b9935b81b9276351.zip |
Approvals at Branch Protection (#5350)
* Add branch protection for approvals
Signed-off-by: Jonas Franz <info@jonasfranz.software>
* Add required approvals
Signed-off-by: Jonas Franz <info@jonasfranz.software>
* Add missing comments and fmt
Signed-off-by: Jonas Franz <info@jonasfranz.software>
* Add type = approval and group by reviewer_id to review
* Prevent users from adding negative review limits
* Add migration for approval whitelists
Signed-off-by: Jonas Franz <info@jonasfranz.software>
Diffstat (limited to 'models/review.go')
-rw-r--r-- | models/review.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/models/review.go b/models/review.go index 3ae1dd457c..91b6d6dbb2 100644 --- a/models/review.go +++ b/models/review.go @@ -161,6 +161,23 @@ func GetReviewByID(id int64) (*Review, error) { return getReviewByID(x, id) } +func getUniqueApprovalsByPullRequestID(e Engine, prID int64) (reviews []*Review, err error) { + reviews = make([]*Review, 0) + if err := e. + Where("issue_id = ? AND type = ?", prID, ReviewTypeApprove). + OrderBy("updated_unix"). + GroupBy("reviewer_id"). + Find(&reviews); err != nil { + return nil, err + } + return +} + +// GetUniqueApprovalsByPullRequestID returns all reviews submitted for a specific pull request +func GetUniqueApprovalsByPullRequestID(prID int64) ([]*Review, error) { + return getUniqueApprovalsByPullRequestID(x, prID) +} + // FindReviewOptions represent possible filters to find reviews type FindReviewOptions struct { Type ReviewType |