Commit d535f3d8 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

feat(core): allows transforms to have custom MR message

parent 0fbbee2b9950
......@@ -323,6 +323,13 @@ class Command:
NO_AUTO_MR = False
TARGETS = ("cubes", "clients")
merge_request_description = (
"Hello dear contributors,\n\nThis is an auto generated modification to help you improve the"
" code base of logilab. If this commit is bad don't hesitate to close this MR and report it"
" here https://forge.extranet.logilab.fr/cubicweb/cube-doctor/-/issues."
"\n\nKind regards,"
)
def pre_check(self, root_files):
return
......@@ -439,6 +446,13 @@ class Command:
else:
commit_message = metadata["commit_message"]
if "merge_request_description" in metadata:
merge_request_description = metadata[
"merge_request_description"
]
else:
merge_request_description = self.merge_request_description
# if nothing has changed, continue
if not repo.run_command("hg status", capture_output=True):
logger.info("nothing has changed, skip")
......@@ -551,12 +565,7 @@ class Command:
"source_branch": branch_name,
"title": commit_message[:254],
"labels": ["To Review"],
"description": "Hello dear contributors,\n\nThis is an "
"auto generated modification to help you improve the code base "
"of logilab. If this commit is bad don't hesitate to close "
"this MR and report it here "
"https://forge.extranet.logilab.fr/cubicweb/cube-doctor/-/issues."
"\n\nKind regards,",
"description": merge_request_description,
}
)
print(f"\n=> MR created at {mr.attributes['web_url']} \\o/\n")
......@@ -579,9 +588,17 @@ class Command:
print("ERROR: you aren't allowed to merge this MR")
break
else:
cube.mergerequests.get(mr.iid).merge(
merge_when_pipeline_succeeds=True
)
try:
cube.mergerequests.get(mr.iid).merge(
merge_when_pipeline_succeeds=True
)
except gitlab.exceptions.GitlabMRClosedError:
import traceback
traceback.print_exc()
logger.error(
f"failed to mark MR {mr} on {cube.name} as merge_when_pipeline_succeeds"
)
open("created_mr.log", "a").write(
f"{branch_name.split('/')[-1]}: {mr.attributes['web_url']}\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment