@@ -223,42 +223,34 @@ def queue_pr_comment_task_if_needed(
223
223
except NotImplementedError :
224
224
return
225
225
226
+ if not OrganizationOption .objects .get_value (
227
+ organization = project .organization ,
228
+ key = pr_comment_workflow .organization_option_key ,
229
+ default = True ,
230
+ ):
231
+ return
232
+
233
+ repo_query = Repository .objects .filter (id = commit .repository_id ).order_by ("-date_added" )
234
+ group = Group .objects .get_from_cache (id = group_id )
235
+ if not (
236
+ group .level is not logging .INFO and repo_query .exists ()
237
+ ): # Don't comment on info level issues
238
+ return
239
+
226
240
with CommitContextIntegrationInteractionEvent (
227
241
interaction_type = SCMIntegrationInteractionType .QUEUE_COMMENT_TASK ,
228
242
provider_key = self .integration_name ,
229
243
organization = project .organization ,
230
244
project = project ,
231
245
commit = commit ,
232
246
).capture () as lifecycle :
233
- if not OrganizationOption .objects .get_value (
234
- organization = project .organization ,
235
- key = pr_comment_workflow .organization_option_key ,
236
- default = True ,
237
- ):
238
- # TODO: remove logger in favor of the log recorded in lifecycle.record_halt
239
- logger .info (
240
- _pr_comment_log (integration_name = self .integration_name , suffix = "disabled" ),
241
- extra = {"organization_id" : project .organization_id },
242
- )
243
- lifecycle .record_halt (CommitContextHaltReason .PR_BOT_DISABLED )
244
- return
245
-
246
- repo_query = Repository .objects .filter (id = commit .repository_id ).order_by ("-date_added" )
247
- group = Group .objects .get_from_cache (id = group_id )
248
- if not (
249
- group .level is not logging .INFO and repo_query .exists ()
250
- ): # Don't comment on info level issues
251
- logger .info (
252
- _pr_comment_log (
253
- integration_name = self .integration_name , suffix = "incorrect_repo_config"
254
- ),
255
- extra = {"organization_id" : project .organization_id },
256
- )
257
- lifecycle .record_halt (CommitContextHaltReason .INCORRECT_REPO_CONFIG )
258
- return
259
-
260
247
repo : Repository = repo_query .get ()
261
- lifecycle .add_extra ("repository_id" , repo .id )
248
+ lifecycle .add_extras (
249
+ {
250
+ "repository_id" : repo .id ,
251
+ "group_id" : group_id ,
252
+ }
253
+ )
262
254
263
255
logger .info (
264
256
_pr_comment_log (
@@ -282,37 +274,18 @@ def queue_pr_comment_task_if_needed(
282
274
return
283
275
284
276
if merge_commit_sha is None :
285
- logger .info (
286
- _pr_comment_log (
287
- integration_name = self .integration_name ,
288
- suffix = "queue_comment_workflow.commit_not_in_default_branch" ,
289
- ),
290
- extra = {
291
- "organization_id" : commit .organization_id ,
292
- "repository_id" : repo .id ,
293
- "commit_sha" : commit .key ,
294
- },
295
- )
277
+ lifecycle .add_extra ("commit_sha" , commit .key )
296
278
lifecycle .record_halt (CommitContextHaltReason .COMMIT_NOT_IN_DEFAULT_BRANCH )
297
279
return
298
280
281
+ lifecycle .add_extra ("merge_commit_sha" , merge_commit_sha )
282
+
299
283
pr_query = PullRequest .objects .filter (
300
284
organization_id = commit .organization_id ,
301
285
repository_id = commit .repository_id ,
302
286
merge_commit_sha = merge_commit_sha ,
303
287
)
304
288
if not pr_query .exists ():
305
- logger .info (
306
- _pr_comment_log (
307
- integration_name = self .integration_name ,
308
- suffix = "queue_comment_workflow.missing_pr" ,
309
- ),
310
- extra = {
311
- "organization_id" : commit .organization_id ,
312
- "repository_id" : repo .id ,
313
- "commit_sha" : commit .key ,
314
- },
315
- )
316
289
lifecycle .record_halt (CommitContextHaltReason .MISSING_PR )
317
290
return
318
291
0 commit comments