@@ -104,7 +104,7 @@ func (protectBranch *ProtectedBranch) CanUserPush(userID int64) bool {
104104}
105105
106106// IsUserMergeWhitelisted checks if some user is whitelisted to merge to this branch
107- func IsUserMergeWhitelisted (protectBranch * ProtectedBranch , userID int64 , permissionInRepo Permission ) bool {
107+ func IsUserMergeWhitelisted (ctx context. Context , protectBranch * ProtectedBranch , userID int64 , permissionInRepo Permission ) bool {
108108 if ! protectBranch .EnableMergeWhitelist {
109109 // Then we need to fall back on whether the user has write permission
110110 return permissionInRepo .CanWrite (unit .TypeCode )
@@ -118,7 +118,7 @@ func IsUserMergeWhitelisted(protectBranch *ProtectedBranch, userID int64, permis
118118 return false
119119 }
120120
121- in , err := organization .IsUserInTeams (db . DefaultContext , userID , protectBranch .MergeWhitelistTeamIDs )
121+ in , err := organization .IsUserInTeams (ctx , userID , protectBranch .MergeWhitelistTeamIDs )
122122 if err != nil {
123123 log .Error ("IsUserInTeams: %v" , err )
124124 return false
@@ -159,16 +159,16 @@ func isUserOfficialReviewer(ctx context.Context, protectBranch *ProtectedBranch,
159159}
160160
161161// HasEnoughApprovals returns true if pr has enough granted approvals.
162- func (protectBranch * ProtectedBranch ) HasEnoughApprovals (pr * PullRequest ) bool {
162+ func (protectBranch * ProtectedBranch ) HasEnoughApprovals (ctx context. Context , pr * PullRequest ) bool {
163163 if protectBranch .RequiredApprovals == 0 {
164164 return true
165165 }
166- return protectBranch .GetGrantedApprovalsCount (pr ) >= protectBranch .RequiredApprovals
166+ return protectBranch .GetGrantedApprovalsCount (ctx , pr ) >= protectBranch .RequiredApprovals
167167}
168168
169169// GetGrantedApprovalsCount returns the number of granted approvals for pr. A granted approval must be authored by a user in an approval whitelist.
170- func (protectBranch * ProtectedBranch ) GetGrantedApprovalsCount (pr * PullRequest ) int64 {
171- sess := db .GetEngine (db . DefaultContext ).Where ("issue_id = ?" , pr .IssueID ).
170+ func (protectBranch * ProtectedBranch ) GetGrantedApprovalsCount (ctx context. Context , pr * PullRequest ) int64 {
171+ sess := db .GetEngine (ctx ).Where ("issue_id = ?" , pr .IssueID ).
172172 And ("type = ?" , ReviewTypeApprove ).
173173 And ("official = ?" , true ).
174174 And ("dismissed = ?" , false )
@@ -185,11 +185,11 @@ func (protectBranch *ProtectedBranch) GetGrantedApprovalsCount(pr *PullRequest)
185185}
186186
187187// MergeBlockedByRejectedReview returns true if merge is blocked by rejected reviews
188- func (protectBranch * ProtectedBranch ) MergeBlockedByRejectedReview (pr * PullRequest ) bool {
188+ func (protectBranch * ProtectedBranch ) MergeBlockedByRejectedReview (ctx context. Context , pr * PullRequest ) bool {
189189 if ! protectBranch .BlockOnRejectedReviews {
190190 return false
191191 }
192- rejectExist , err := db .GetEngine (db . DefaultContext ).Where ("issue_id = ?" , pr .IssueID ).
192+ rejectExist , err := db .GetEngine (ctx ).Where ("issue_id = ?" , pr .IssueID ).
193193 And ("type = ?" , ReviewTypeReject ).
194194 And ("official = ?" , true ).
195195 And ("dismissed = ?" , false ).
@@ -204,11 +204,11 @@ func (protectBranch *ProtectedBranch) MergeBlockedByRejectedReview(pr *PullReque
204204
205205// MergeBlockedByOfficialReviewRequests block merge because of some review request to official reviewer
206206// of from official review
207- func (protectBranch * ProtectedBranch ) MergeBlockedByOfficialReviewRequests (pr * PullRequest ) bool {
207+ func (protectBranch * ProtectedBranch ) MergeBlockedByOfficialReviewRequests (ctx context. Context , pr * PullRequest ) bool {
208208 if ! protectBranch .BlockOnOfficialReviewRequests {
209209 return false
210210 }
211- has , err := db .GetEngine (db . DefaultContext ).Where ("issue_id = ?" , pr .IssueID ).
211+ has , err := db .GetEngine (ctx ).Where ("issue_id = ?" , pr .IssueID ).
212212 And ("type = ?" , ReviewTypeRequest ).
213213 And ("official = ?" , true ).
214214 Exist (new (Review ))
0 commit comments