mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-06 02:15:20 +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:
parent
64680b72bd
commit
9681c83734
13 changed files with 251 additions and 41 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue