From 3d9524b4e44a11a7d12d0ecf8d629e4eacdac208 Mon Sep 17 00:00:00 2001 From: Meni Yakove Date: Sat, 20 Jul 2024 13:27:36 +0300 Subject: [PATCH] Fix where is no last commiter in commit --- Dockerfile | 14 +++++++------- webhook_server_container/libs/github_api.py | 11 +++++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3cfc65e8..1b288a39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,13 +16,13 @@ RUN mkdir -p $USER_BIN_DIR \ && mkdir -p $DATA_DIR/logs \ && mkdir -p /tmp/containers -RUN set -x \ - && curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash \ - && curl https://mirror.openshift.com/pub/openshift-v4/clients/rosa/latest/rosa-linux.tar.gz --output /tmp/rosa-linux.tar.gz \ - && tar xvf /tmp/rosa-linux.tar.gz --no-same-owner \ - && mv rosa $USER_BIN_DIR/rosa \ - && chmod +x $USER_BIN_DIR/rosa \ - && rm -rf /tmp/rosa-linux.tar.gz +# RUN set -x \ +# && curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash \ +# && curl https://mirror.openshift.com/pub/openshift-v4/clients/rosa/latest/rosa-linux.tar.gz --output /tmp/rosa-linux.tar.gz \ +# && tar xvf /tmp/rosa-linux.tar.gz --no-same-owner \ +# && mv rosa $USER_BIN_DIR/rosa \ +# && chmod +x $USER_BIN_DIR/rosa \ +# && rm -rf /tmp/rosa-linux.tar.gz RUN ln -s /usr/bin/python3 /usr/bin/python diff --git a/webhook_server_container/libs/github_api.py b/webhook_server_container/libs/github_api.py index 1f6ed48e..30105b59 100644 --- a/webhook_server_container/libs/github_api.py +++ b/webhook_server_container/libs/github_api.py @@ -113,6 +113,8 @@ def __init__(self, hook_data: Dict[Any, Any], headers: Headers): self.x_github_delivery: str = self.headers.get("X-GitHub-Delivery", "") self.github_event: str = self.headers["X-GitHub-Event"] self.log_prefix = self.prepare_log_prefix() + self.owners_content: Dict[str, Any] = {} + self._repo_data_from_config() self.github_app_api = get_repository_github_app_api( @@ -144,7 +146,6 @@ def __init__(self, hook_data: Dict[Any, Any], headers: Headers): self.add_api_users_to_auto_verified_and_merged_users() self.clone_repository_path: str = os.path.join("/", self.repository.name) - self.owners_content = self.get_owners_content() self.supported_user_labels_str: str = "".join([f" * {label}\n" for label in USER_LABELS_DICT.keys()]) self.welcome_msg: str = f""" Report bugs in [Issues](https://github.com/myakove/github-webhook-server/issues) @@ -193,10 +194,10 @@ def process(self) -> None: self.pull_request = self._get_pull_request() self.log_prefix = self.prepare_log_prefix(pull_request=self.pull_request) LOGGER.info(f"{self.log_prefix} {event_log}") - + self.owners_content = self.get_owners_content() self.last_commit = self._get_last_commit() self.parent_committer = self.pull_request.user.login - self.last_committer = self.last_commit.committer.login + self.last_committer = getattr(self.last_commit.committer, "login", self.parent_committer) self.pull_request_branch = self.pull_request.base.ref if self.jira_enabled_repository: @@ -234,7 +235,9 @@ def process(self) -> None: self.process_pull_request_check_run_webhook_data() except NoPullRequestError: - LOGGER.info(f"{self.log_prefix} {event_log}") + LOGGER.info(f"{self.log_prefix} {event_log}. [No pull request found in hook data]") + self.owners_content = self.get_owners_content() + if self.github_event == "push": self.process_push_webhook_data()