Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cube-doctor
Commits
818ef2394483
Commit
d535f3d8
authored
Sep 16, 2021
by
Laurent Peuch
Browse files
feat(core): allows transforms to have custom MR message
parent
0fbbee2b9950
Changes
1
Hide whitespace changes
Inline
Side-by-side
cube_doctor/__init__.py
View file @
818ef239
...
@@ -323,6 +323,13 @@ class Command:
...
@@ -323,6 +323,13 @@ class Command:
NO_AUTO_MR
=
False
NO_AUTO_MR
=
False
TARGETS
=
(
"cubes"
,
"clients"
)
TARGETS
=
(
"cubes"
,
"clients"
)
merge_request_description
=
(
"Hello dear contributors,
\n\n
This 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\n
Kind regards,"
)
def
pre_check
(
self
,
root_files
):
def
pre_check
(
self
,
root_files
):
return
return
...
@@ -439,6 +446,13 @@ class Command:
...
@@ -439,6 +446,13 @@ class Command:
else
:
else
:
commit_message
=
metadata
[
"commit_message"
]
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 nothing has changed, continue
if
not
repo
.
run_command
(
"hg status"
,
capture_output
=
True
):
if
not
repo
.
run_command
(
"hg status"
,
capture_output
=
True
):
logger
.
info
(
"nothing has changed, skip"
)
logger
.
info
(
"nothing has changed, skip"
)
...
@@ -551,12 +565,7 @@ class Command:
...
@@ -551,12 +565,7 @@ class Command:
"source_branch"
:
branch_name
,
"source_branch"
:
branch_name
,
"title"
:
commit_message
[:
254
],
"title"
:
commit_message
[:
254
],
"labels"
:
[
"To Review"
],
"labels"
:
[
"To Review"
],
"description"
:
"Hello dear contributors,
\n\n
This is an "
"description"
:
merge_request_description
,
"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\n
Kind regards,"
,
}
}
)
)
print
(
f
"
\n
=> MR created at
{
mr
.
attributes
[
'web_url'
]
}
\\
o/
\n
"
)
print
(
f
"
\n
=> MR created at
{
mr
.
attributes
[
'web_url'
]
}
\\
o/
\n
"
)
...
@@ -579,9 +588,17 @@ class Command:
...
@@ -579,9 +588,17 @@ class Command:
print
(
"ERROR: you aren't allowed to merge this MR"
)
print
(
"ERROR: you aren't allowed to merge this MR"
)
break
break
else
:
else
:
cube
.
mergerequests
.
get
(
mr
.
iid
).
merge
(
try
:
merge_when_pipeline_succeeds
=
True
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
(
open
(
"created_mr.log"
,
"a"
).
write
(
f
"
{
branch_name
.
split
(
'/'
)[
-
1
]
}
:
{
mr
.
attributes
[
'web_url'
]
}
\n
"
f
"
{
branch_name
.
split
(
'/'
)[
-
1
]
}
:
{
mr
.
attributes
[
'web_url'
]
}
\n
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment