From 29f12f9468cd291710e8eb90f21997e4afb43b09 Mon Sep 17 00:00:00 2001 From: Niklas Stoffers <74815146+niklasstoffers@users.noreply.github.com> Date: Sat, 23 Dec 2023 00:49:57 +0100 Subject: [PATCH] Fix swapped strict_match check and wrong approval access --- src/services/gitlab/events/comment/comment_event_service.py | 4 ++-- src/services/gitlab/gitlab_client.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/gitlab/events/comment/comment_event_service.py b/src/services/gitlab/events/comment/comment_event_service.py index e626ff4..328b313 100644 --- a/src/services/gitlab/events/comment/comment_event_service.py +++ b/src/services/gitlab/events/comment/comment_event_service.py @@ -21,8 +21,8 @@ def __is_command_invocation(self, event: CommentEvent, command: Command): message = message.lower() if command.strict_match: - return keyword in message - return keyword == message + return keyword == message + return keyword in message def __handle_merge_comment(self, event: CommentEvent): if event.merge_request is None: diff --git a/src/services/gitlab/gitlab_client.py b/src/services/gitlab/gitlab_client.py index e2820e3..0b9f9c7 100644 --- a/src/services/gitlab/gitlab_client.py +++ b/src/services/gitlab/gitlab_client.py @@ -22,7 +22,7 @@ def get_merge_request(self, project_id: int, merge_request_iid: int) -> ProjectM def is_merge_request_approved_by(self, merge_request: ProjectMergeRequest, username: str) -> bool: approvals: ProjectMergeRequestApproval = merge_request.approvals.get() for approval in approvals.attributes["approved_by"]: - if approval.user is not None and approval.user.username == username: + if approval['user']['username'] == username: return True return False