mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-22 05:58:02 +02:00
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>
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user