From 430ca82be6ad4912eb53a384ff42d585a96eab67 Mon Sep 17 00:00:00 2001 From: rnetser Date: Tue, 23 Jul 2024 15:56:46 +0300 Subject: [PATCH] set wip label based on title --- webhook_server_container/libs/github_api.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/webhook_server_container/libs/github_api.py b/webhook_server_container/libs/github_api.py index 56522c78..392e619a 100644 --- a/webhook_server_container/libs/github_api.py +++ b/webhook_server_container/libs/github_api.py @@ -884,6 +884,9 @@ def process_pull_request_webhook_data(self) -> None: self.parent_committer = pull_request_data["user"]["login"] self.pull_request_branch = pull_request_data["base"]["ref"] + if hook_action == "edited": + self.set_wip_label_based_on_title() + if hook_action == "opened": self.logger.info(f"{self.log_prefix} Creating welcome comment") self.pull_request.create_issue_comment(self.welcome_msg) @@ -891,6 +894,8 @@ def process_pull_request_webhook_data(self) -> None: self.process_opened_or_synchronize_pull_request() + self.set_wip_label_based_on_title() + if self.jira_track_pr: jira_conn = self.get_jira_conn() if not jira_conn: @@ -1902,3 +1907,10 @@ def get_all_required_status_checks(self) -> List[str]: _all_required_status_checks = branch_required_status_checks + all_required_status_checks self.logger.debug(f"{self.log_prefix} All required status checks: {_all_required_status_checks}") return _all_required_status_checks + + def set_wip_label_based_on_title(self) -> None: + if self.pull_request.title.lower().startswith("{WIP_STR}:"): + self._add_label(label=WIP_STR) + + else: + self._remove_label(label=WIP_STR)