diff --git a/check_if_integration_branch_is_up_to_date.py b/check_if_integration_branch_is_up_to_date.py index 0058e9d613c0ed20ef81620ee974c15e90dc9f8e..460f3312b099730629844b9854c57a0c80a9ddf5 100755 --- a/check_if_integration_branch_is_up_to_date.py +++ b/check_if_integration_branch_is_up_to_date.py @@ -16,14 +16,13 @@ def check_if_integration_branch_is_up_to_date( integration_branch = None branch_list = [] - if merge_request.source_branch.startswith("integrate/gitlab-ci"): + if common.is_gitlab_ci_integration_branch(merge_request.source_branch): 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 pass @@ -40,9 +39,7 @@ def check_if_integration_branch_is_up_to_date( except GitlabGetError: sys.exit( "ERROR: could not find integration branch in {}," - "branch names checked: {}\n".format( - manifest_project.name, - branch_list) + "branch names checked: {}\n".format(manifest_project.name, branch_list) ) try: diff --git a/common.py b/common.py index ab6093c407b58f48a4af2e7b3262f967a07032d8..0632511906817dbf2719fdd7b6169260d98b8996 100755 --- a/common.py +++ b/common.py @@ -22,6 +22,11 @@ def integration_branch_name(project_name, branch_name): return "integrate/" + project_name.lower() + "/" + branch_name +def is_gitlab_ci_integration_branch(branch_name): + gitlab_ci_integration_branch = "integrate/.gitlab_ci" + return branch_name.startswith(gitlab_ci_integration_branch) + + def find_gitlab_ci_integration_branch(repo: Repo, branch_name): """ # Special handling for the gitlab-ci integration @@ -29,7 +34,7 @@ def find_gitlab_ci_integration_branch(repo: Repo, branch_name): # integrate/gitlab-ci we add our new commit to this branch # Otherwise (normal behaviour) a new integration branch is created """ - if not branch_name.startswith("integrate/gitlab-ci"): + if not is_gitlab_ci_integration_branch(branch_name): return None logging.debug("Integration of gitlab-ci: %s", branch_name) diff --git a/merge_gitlab_ci.py b/merge_gitlab_ci.py index 37a6c72e5f3d4648dec9ba1700d83c0ad8c9ec4e..dfabc8417f7684563d6e0f9883cde3e4620b3eba 100755 --- a/merge_gitlab_ci.py +++ b/merge_gitlab_ci.py @@ -134,10 +134,9 @@ def main(): # Start with the manifest here, so the subproject # can see that they are already integrated - for p in [args.project] + args.projects: + for p in args.projects + [args.project]: project = common.get_project(gitlab, p) branch = args.branch - should_remove_source_branch = True if branch is None: branch = project.default_branch @@ -161,10 +160,6 @@ def main(): if p == args.project: manifest_project = project manifest_integration_mr = mr - # For the manifest we keep the source branch - # otherwise does the check job fail for not yet merged - # child projects - should_remove_source_branch = False print("Merge {}!{}: {}".format(project.name, mr.iid, mr.title)) # Wait until GitLab has checked merge status @@ -176,8 +171,8 @@ def main(): mr, # Only the file manifest commit may be rebased # other rebase would require new integration commits + # TODO implement rebase rebase=(p == args.project), - should_remove_source_branch=should_remove_source_branch, ) if not merged: diff --git a/merge_into_manifest.py b/merge_into_manifest.py index 7c656096897e5305b28d854cc95ba25a253dd1b6..e3c6c4fcbd5254465197cba3d1c3d2833e1cf046 100755 --- a/merge_into_manifest.py +++ b/merge_into_manifest.py @@ -10,7 +10,6 @@ from accept_merge_request import accept_merge_request from create_merge_request import create_merge_request from get_merge_requests import get_merge_requests from integrate_into_manifest import integrate_into_manifest -from get_current_revision_from_manifest import get_current_revision_from_manifest def merge_into_manifest( @@ -28,28 +27,6 @@ def merge_into_manifest( the current manifest master. """ - # Check if the commit is already merged - # Currently this is especially true if the gitlab-ci - # pipeline already has merged an gitlab-ci update - current_revisions = get_current_revision_from_manifest( - manifest_project=manifest_project, - manifest_branch=master_branch, - project=project, - recipe_name=recipe_name, - srcrev_file=srcrev_file, - ) - logging.debug(current_revisions) - # This commit is contained there if current_revisions contains - # it directly or any parrent of current_revisions is commit - for rev in current_revisions.values(): - if common.is_commit_parent_of_project_commit(project, rev, commit): - print( - "Commit {} is already merged into {}".format( - commit, manifest_project.name - ) - ) - return "" - # Get source merge request mrs = get_merge_requests( project, @@ -65,6 +42,13 @@ def merge_into_manifest( # Get original branch for commit original_branch = source_mr.source_branch + + if common.is_gitlab_ci_integration_branch(original_branch): + print( + "Commit {} is a gitlab-ci integration branch and will be merged by the gitlab-ci pipeline." + ) + return "" + integration_branch = common.integration_branch_name(project.name, original_branch) target_branch = master_branch