From 30f7d966cadcbaccbcfe01fd8642a49b967722fe Mon Sep 17 00:00:00 2001 From: Tim Jaacks <tim.jaacks@seco.com> Date: Thu, 10 Aug 2023 12:31:09 +0200 Subject: [PATCH] update_submodule: fix integration branch name in case of multiple MRs When there are multiple open merge requests for a commit, we currently take the newest one to determine the integration branch name. This is not necessarily the correct one, we can have an open merge request with the commit being part of the commit history while the top commit is a different one. Add a check if the commit is the top commit of the merge request in order to get the correct integration branch name in these cases. --- scripts/update_submodule.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/update_submodule.py b/scripts/update_submodule.py index 9561d916..ff8ee342 100755 --- a/scripts/update_submodule.py +++ b/scripts/update_submodule.py @@ -241,12 +241,15 @@ def update_submodule_and_include_ref( return None, None, None, None, None logging.debug("New commits: %s", commits) - # Find out if top commit is part of a merge request + # Find out if top commit is top commit of a merge request # If so, use source branch of this MR as integration branch name # Else use commit sha instead integration_branch_suffix = new_revision for mr in commits[0].merge_requests(): - if mr["target_branch"] == submodule_project.default_branch: + if ( + mr["target_branch"] == submodule_project.default_branch + and mr["sha"] == new_revision + ): integration_branch_suffix = mr["source_branch"] break logging.debug("Integration branch suffix: %s", integration_branch_suffix) -- GitLab