Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • seco-ne/yocto/infrastructure/gitlab-ci
1 result
Show changes
Commits on Source (1)
......@@ -19,7 +19,7 @@ critical_error = (
)
def accept_merge_request(project, mr, rebase=False):
def accept_merge_request(project, mr, rebase=False, should_remove_source_branch=True):
"""Attempt to merge a merge request, rebase if necessary"""
merged = False
pipeline_pending = False
......@@ -37,7 +37,7 @@ def accept_merge_request(project, mr, rebase=False):
# Try to merge the merge request
try:
mr.merge(should_remove_source_branch=True)
mr.merge(should_remove_source_branch=should_remove_source_branch)
if pipeline_pending:
print("")
if mr.state == "merged":
......
......@@ -15,12 +15,14 @@ def check_if_integration_branch_is_up_to_date(
):
integration_branch = None
branch_list = []
if merge_request.source_branch.startswith("integrate/gitlab-ci"):
try:
integration_branch = manifest_project.branches.get(
merge_request.source_branch,
retry_transient_errors=True,
)
branch_list.append(merge_request.source_branch)
except GitlabGetError:
# Branch not found
......@@ -29,13 +31,19 @@ def check_if_integration_branch_is_up_to_date(
integration_branch_name = common.integration_branch_name(
project.name, merge_request.source_branch
)
branch_list.append(integration_branch)
try:
integration_branch = manifest_project.branches.get(
integration_branch_name,
retry_transient_errors=True,
)
except GitlabGetError:
sys.exit("ERROR: could not find integration branch\n")
sys.exit(
"ERROR: could not find integration branch in %s,"
"branch names checked: %s\n",
manifest_project.name,
branch_list,
)
try:
integration_base_branch = manifest_project.branches.get(
......
......@@ -280,7 +280,7 @@ def is_commit_parent_of_project_commit(project: Project, project_commit, commit)
) from e
# The integration branch is up to date if its parent is the integration base
logging.debug("Compare '%s' and '%s'",parent.id, commit)
logging.debug("Compare '%s' and '%s'", parent.id, commit)
if parent.id == commit:
return True
if len(parent.parent_ids) == 0:
......
......@@ -156,6 +156,11 @@ def main():
# deploy_gitlab_ci again to create a new integration
# commit or make sure the change is already integrated.
# Store for later usage:
if p == args.project:
manifest_project = project
manifest_integration_mr = mr
print("Merge {}!{}: {}".format(project.name, mr.iid, mr.title))
# Wait until GitLab has checked merge status
common.wait_until_merge_status_is_set(project, mr)
......@@ -167,6 +172,10 @@ def main():
# Only the file manifest commit may be rebased
# other rebase would require new integration commits
rebase=(p == args.project),
# For the manifest we keep the source branch
# otherwise does the check job fail for not yet merged
# child projects
should_remove_source_branch=(p == args.project),
)
if not merged:
......@@ -185,9 +194,18 @@ def main():
continue
if not found:
continue
print(" {}".format(p2.name))
print(" {}".format(p2))
sys.exit()
# Delete args.project (manifests) integration branch
# (skipped the deletion during the merge request merge before)
integration_branch = manifest_project.branches.get(
manifest_integration_mr.source_branch
)
manifest_project.branches.delete(
integration_branch.get_id(), retry_transient_errors=True
)
print("Successfully merged")
exit()
......