Skip to content

Commit

Permalink
Revert "[#3844] Bug/Enqueued Action"
Browse files Browse the repository at this point in the history
This reverts commit 8436c16.
  • Loading branch information
nickmango committed Jul 17, 2023
1 parent 0daec65 commit 7822ba7
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cla-backend/cla/models/github_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_repository_id(self, repo_name, installation_id=None):

def received_activity(self, data):
cla.log.debug('github_models.received_activity - Received GitHub activity: %s', data)
if 'pull_request' not in data:
if 'pull_request' not in data and 'merge_group' not in data:
cla.log.debug('github_models.received_activity - Activity not related to pull request - ignoring')
return {'message': 'Not a pull request nor a merge group - no action performed'}
if data['action'] == 'opened':
Expand All @@ -83,9 +83,9 @@ def received_activity(self, data):
elif data['action'] == 'synchronize':
cla.log.debug('github_models.received_activity - Handling synchronized pull request')
return self.process_synchronized_pull_request(data)
elif data['action'] == 'enqueued': # Handle new github feature for merge queue
elif data['action'] == 'checks_requested':
cla.log.debug('github_models.received_activity - Handling checks requested pull request')
return self.process_checks_enqueued_entry(data)
return self.process_checks_requested_merge_group(data)
else:
cla.log.debug('github_models.received_activity - Ignoring unsupported action: {}'.format(data['action']))

Expand Down Expand Up @@ -327,19 +327,21 @@ def process_opened_pull_request(self, data):
installation_id = data['installation']['id']
self.update_change_request(installation_id, github_repository_id, pull_request_id)

def process_checks_enqueued_entry(self, data):
def process_checks_requested_merge_group(self, data):
"""
Helper method to handle a webhook fired from GitHub for a merge group event.
:param data: The data returned from GitHub on this webhook.
:type data: dict
"""
pull_request_id = data['pull_request']['number']
merge_commit_sha = data['pull_request']['merge_commit_sha']
merge_group_sha = data['merge_group']['head_sha']
github_repository_id = data['repository']['id']
installation_id = data['installation']['id']
pull_request_message = data['merge_group']['head_commit']['message']

self.update_queue_entry(installation_id, github_repository_id, merge_commit_sha, pull_request_id)
# Extract the pull request number from the message
pull_request_id = cla.utils.extract_pull_request_number(pull_request_message)
self.update_merge_group(installation_id, github_repository_id, merge_group_sha, pull_request_id)

def process_easycla_command_comment(self, data):
"""
Expand Down Expand Up @@ -512,7 +514,7 @@ def update_merge_group_status(self,installation_id, repository_id, pull_request,

create_commit_status_for_merge_group(commit_obj,merge_commit_sha, state, sign_url, body, context)

def update_queue_entry(self, installation_id, github_repository_id, merge_group_sha, pull_request_id):
def update_merge_group(self, installation_id, github_repository_id, merge_group_sha, pull_request_id):
fn = 'update_queue_entry'

# Note: late 2021/early 2022 we observed that sometimes we get the event for a PR, then go back to GitHub
Expand Down

0 comments on commit 7822ba7

Please sign in to comment.