From 872ec6d9c07b199214a894be9b7a428b0520c47b Mon Sep 17 00:00:00 2001 From: Tim Jaacks <tim.jaacks@seco.com> Date: Thu, 3 Aug 2023 10:33:56 +0200 Subject: [PATCH] Refactoring: swap if and else branches Move the main part of the action to the if branch. See for reference: https://docs.sourcery.ai/Reference/Python/Default-Rules/swap-if-else-branches/ --- scripts/update_submodule.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/update_submodule.py b/scripts/update_submodule.py index 4e047c81..9561d916 100755 --- a/scripts/update_submodule.py +++ b/scripts/update_submodule.py @@ -298,13 +298,9 @@ def update_submodule_and_include_ref( logging.debug("Head of %s points to %s", branch, integration_base_id) # Loop over the commits until the integration_branch head id is found - if not common.is_commit_parent_of_project_commit( + if common.is_commit_parent_of_project_commit( project, existing_branch.commit["id"], integration_base_id, limit=5 ): - logging.debug("Integration branch is outdated, delete it.") - project.branches.delete(existing_branch.name) - existing_branch = None - else: # Check the submodule revision on the integration branch ( _, @@ -325,6 +321,10 @@ def update_submodule_and_include_ref( ) integration_commit = existing_branch.commit["id"] submodule_update_needed = False + else: + logging.debug("Integration branch is outdated, delete it.") + project.branches.delete(existing_branch.name) + existing_branch = None # Clone the project, we need to do changes if submodule_update_needed or force_clone: -- GitLab