Skip to content

Commit 1d80a76

Browse files
Merge branch 'dev' into unicron-fix-github-installation-and-merge-queue
Assisted by [OpenAI](https://platform.openai.com/) Assisted by [GitHub Copilot](https://github.com/features/copilot)
2 parents 60a5b13 + 0799a5d commit 1d80a76

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

cla-backend/cla/models/github_models.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ def received_activity(self, data):
139139
elif data["action"] == "checks_requested":
140140
cla.log.debug("github_models.received_activity - Handling checks requested pull request")
141141
return self.process_checks_requested_merge_group(data)
142+
elif data["action"] == "enqueued":
143+
cla.log.debug("github_models.received_activity - Handling enqueued pull request")
144+
return self.process_enqueued_pull_request(data)
142145
else:
143146
cla.log.debug("github_models.received_activity - Ignoring unsupported action: {}".format(data["action"]))
144147

@@ -456,6 +459,30 @@ def process_opened_pull_request(self, data):
456459
installation_id = data["installation"]["id"]
457460
self.update_change_request(installation_id, github_repository_id, pull_request_id)
458461

462+
def process_enqueued_pull_request(self, data):
463+
"""
464+
Helper method to handle a webhook fired from GitHub for an enqueued PR.
465+
466+
:param data: The data returned from GitHub on this webhook.
467+
:type data: dict
468+
"""
469+
merge_group_sha = data.get("pull_request", {}).get("merge_commit_sha")
470+
github_repository_id = data.get("repository", {}).get("id")
471+
installation_id = data.get("installation", {}).get("id")
472+
pull_request_id = data.get("pull_request", {}).get("number")
473+
if None in (installation_id, github_repository_id, merge_group_sha, pull_request_id):
474+
cla.log.warning(
475+
"process_enqueued_pull_request: Missing required field(s): "
476+
f"installation_id={installation_id}, "
477+
f"github_repository_id={github_repository_id}, "
478+
f"merge_group_sha={merge_group_sha}, "
479+
f"pull_request_id={pull_request_id}. "
480+
"Aborting update_merge_group."
481+
)
482+
return
483+
484+
self.update_merge_group(installation_id, github_repository_id, merge_group_sha, pull_request_id)
485+
459486
def process_checks_requested_merge_group(self, data):
460487
"""
461488
Helper method to handle a webhook fired from GitHub for a merge group event.

0 commit comments

Comments
 (0)