From 7ce0fd7430aa162965ea7fa411806b8379ebf220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=B6ppner?= <jonas.hoeppner@garz-fricke.com> Date: Fri, 25 Mar 2022 10:50:54 +0100 Subject: [PATCH] CI: merge_gitlab_ci: Improve error handling. --- merge_gitlab_ci.py | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/merge_gitlab_ci.py b/merge_gitlab_ci.py index 35963bbb..04af7728 100755 --- a/merge_gitlab_ci.py +++ b/merge_gitlab_ci.py @@ -139,9 +139,20 @@ def main(): if branch is None: branch = project.default_branch + print( + "Try to merge {}({}) into {} ({})".format( + args.submodule, args.revision, project.name, branch + ) + ) + mr = find_integration_merge_request( project, args.submodule, args.revision, branch ) + if mr is None: + sys.exit("ERROR: Failed to find the integration MR.") + # TODO if this ever happens, why ever, we could call + # deploy_gitlab_ci again to create a new integration + # commit or make sure the change is already integrated. print("Merge {}!{}: {}".format(project.name, mr.iid, mr.title)) # Wait until GitLab has checked merge status @@ -157,13 +168,24 @@ def main(): ) if not merged: - sys.exit( - "Integration MR could not be merged. You have two possibilities to fix " - "this:\n" - " 1. Checkout the MR and rebase it on the current master manually, or\n" - " 2. Delete the MR (Edit -> Delete in the MR UI)\n" - "In either case restart this job afterwards in order to get it merged." + print( + "Integration MR could not be merged." + "To fix this:\n" + " 1. Checkout the MR {}!{} and merge it manually.\n" + " 2. Manually merge the follow up MRs in the following project:".format( + project.name, mr.iid + ) ) + found = False + for p2 in args.projects + [args.project]: + if p2 == p: + found = True + continue + if not found: + continue + print(" {}".format(p2.name)) + sys.exit() + print("Successfully merged") exit() -- GitLab