Skip to content
Snippets Groups Projects
Commit 30f7d966 authored by Tim Jaacks's avatar Tim Jaacks
Browse files

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.
parent 438f1e2a
No related branches found
No related tags found
1 merge request!307update_submodule: fix integration branch name in case of multiple MRs
Pipeline #73457 skipped with stage
...@@ -241,12 +241,15 @@ def update_submodule_and_include_ref( ...@@ -241,12 +241,15 @@ def update_submodule_and_include_ref(
return None, None, None, None, None return None, None, None, None, None
logging.debug("New commits: %s", commits) 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 # If so, use source branch of this MR as integration branch name
# Else use commit sha instead # Else use commit sha instead
integration_branch_suffix = new_revision integration_branch_suffix = new_revision
for mr in commits[0].merge_requests(): 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"] integration_branch_suffix = mr["source_branch"]
break break
logging.debug("Integration branch suffix: %s", integration_branch_suffix) logging.debug("Integration branch suffix: %s", integration_branch_suffix)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment