Merge pull request !2789 from rhodecode-enterprise-ce feature/RCCE-258_Update-list-of-warnings-in-PR-when-you-check-delete/close-branch
feature: changes an info message for closing pull request branch
This commit is contained in:
commit
01dca174d2
1 changed files with 30 additions and 7 deletions
|
|
@ -2405,6 +2405,17 @@ class MergeCheck(object):
|
|||
return merge_check
|
||||
|
||||
log.debug("MergeCheck: is failed: %s", merge_check.failed)
|
||||
|
||||
if merge_check.failed:
|
||||
close_branch = PullRequestModel()._close_branch_before_merging(pull_request)
|
||||
if close_branch:
|
||||
close_msg = cls._get_branch_close_or_delete_message(_, pull_request)
|
||||
merge_check.error_details["extra_info"] = {
|
||||
"details": "detailed_info",
|
||||
"message": close_msg,
|
||||
"error_type": "extra_info",
|
||||
}
|
||||
|
||||
return merge_check
|
||||
|
||||
@classmethod
|
||||
|
|
@ -2422,17 +2433,29 @@ class MergeCheck(object):
|
|||
|
||||
close_branch = model._close_branch_before_merging(pull_request)
|
||||
if close_branch:
|
||||
repo_type = pull_request.target_repo.repo_type
|
||||
close_msg = ""
|
||||
if repo_type == "hg":
|
||||
close_msg = _("Source branch will be closed before the merge.")
|
||||
elif repo_type == "git":
|
||||
close_msg = _("Source branch will be deleted after the merge.")
|
||||
|
||||
close_msg = cls._get_branch_close_or_delete_message(_, pull_request)
|
||||
merge_details["close_branch"] = dict(details={}, message=close_msg)
|
||||
|
||||
return merge_details
|
||||
|
||||
@classmethod
|
||||
def _get_branch_close_or_delete_message(cls, translator, pull_request):
|
||||
_ = translator
|
||||
|
||||
repo_type = pull_request.target_repo.repo_type
|
||||
close_msg = ""
|
||||
branch_name = pull_request.source_ref_parts.name
|
||||
max_branch_length = 20
|
||||
shorten_branch_name = (
|
||||
f"{branch_name[:max_branch_length]}..." if len(branch_name) > max_branch_length else branch_name
|
||||
)
|
||||
message_template = "Source branch '%s' will be {action} before the merge." % shorten_branch_name
|
||||
if repo_type == "hg":
|
||||
close_msg = _(message_template.format(action="closed"))
|
||||
elif repo_type == "git":
|
||||
close_msg = _(message_template.format(action="deleted"))
|
||||
return close_msg
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class ChangeTuple:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue