You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Branch protection: Possibility to not use whitelist but allow anyone with write access (#9055)
* Possibility to not use whitelist but allow anyone with write access
* fix existing test
* rename migration function
* Try to give a better name for migration step
* Clear settings if higher level setting is not set
* Move official reviews to db instead of counting approvals each time
* migration
* fix
* fix migration
* fix migration
* Remove NOT NULL from EnableWhitelist as migration isn't possible
* Fix migration, reviews are connected to issues.
* Fix SQL query issues in GetReviewersByPullID.
* Simplify function GetReviewersByIssueID
* Handle reviewers that has been deleted
* Ensure reviews for test is in a well defined order
* Only clear and set official reviews when it is an approve or reject.
if_, err:=sess.Exec("UPDATE `protected_branch` SET `can_push` = `enable_whitelist`"); err!=nil {
38
+
returnerr
39
+
}
40
+
if_, err:=sess.Exec("UPDATE `protected_branch` SET `enable_approvals_whitelist` = ? WHERE `required_approvals` > ?", true, 0); err!=nil {
41
+
returnerr
42
+
}
43
+
44
+
varpageSizeint64=20
45
+
qresult, err:=sess.QueryInterface("SELECT max(id) as max_id FROM issue")
46
+
iferr!=nil {
47
+
returnerr
48
+
}
49
+
vartotalIssuesint64
50
+
totalIssues, ok:=qresult[0]["max_id"].(int64)
51
+
if!ok {
52
+
// If there are no issues at all we ignore it
53
+
returnnil
54
+
}
55
+
totalPages:=totalIssues/pageSize
56
+
57
+
// Find latest review of each user in each pull request, and set official field if appropriate
58
+
reviews:= []*models.Review{}
59
+
varpageint64
60
+
forpage=0; page<=totalPages; page++ {
61
+
iferr:=sess.SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id > ? AND issue_id <= ? AND type in (?, ?) GROUP BY issue_id, reviewer_id)",
0 commit comments