From 6d28d8987362db380c631955b569af1e22701af1 Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Tue, 1 Apr 2025 11:01:06 +0200 Subject: [PATCH] added return guard to remove indent level --- pull_requests.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/pull_requests.py b/pull_requests.py index cea9e1c..819abd6 100644 --- a/pull_requests.py +++ b/pull_requests.py @@ -347,25 +347,28 @@ def process_pull( if all(not comment.file.endswith(".java") for comment in entry.comments): # if the commented files are all not code related, why bother compiling and testing the code? pbar.update(5) - else: - with build_handler: - try: - for message, action in steps: - pbar.set_postfix( - { - "doing": message, - "started at": datetime.now().strftime("%d/%m, %H:%M:%S"), - } - ) - action() - pbar.update(1) - except HandlerException as e: - entry.metadata.last_cmd_error_msg = str(e) - entry.metadata.reason_for_failure = e.reason_for_failure - entry.metadata.successful = False - finally: - build_handler.clean_repo() - reset_repo_to_latest_commit(repo_path) + if entry.metadata.successful: + entry.metadata.reason_for_failure = "Valid PR! But isn't code related though." + return + + with build_handler: + try: + for message, action in steps: + pbar.set_postfix( + { + "doing": message, + "started at": datetime.now().strftime("%d/%m, %H:%M:%S"), + } + ) + action() + pbar.update(1) + except HandlerException as e: + entry.metadata.last_cmd_error_msg = str(e) + entry.metadata.reason_for_failure = e.reason_for_failure + entry.metadata.successful = False + finally: + build_handler.clean_repo() + reset_repo_to_latest_commit(repo_path) if entry.metadata.successful: entry.metadata.reason_for_failure = "Valid PR!" # was set to 'still processing', since it's done being processed and was successful, there are no reasons for failure