edd3e107c6
This adds a Danger check to produce a warning for MR titles greater than 72 characters. This is necessary because when squash on merge is used, the MR title will be used for the commit message (at least by default). This in turn leads to commit messages that violate our commit message guidelines. For more information, refer to https://gitlab.com/gitlab-org/release/framework/issues/24.
32 lines
1.2 KiB
Ruby
32 lines
1.2 KiB
Ruby
# rubocop:disable Style/SignalException
|
|
|
|
if gitlab.mr_body.size < 5
|
|
fail "Please provide a proper merge request description."
|
|
end
|
|
|
|
if gitlab.mr_labels.empty?
|
|
fail "Please add labels to this merge request."
|
|
end
|
|
|
|
unless gitlab.mr_json["assignee"]
|
|
warn "This merge request does not have any assignee yet. Setting an assignee clarifies who needs to take action on the merge request at any given time."
|
|
end
|
|
|
|
has_milestone = !gitlab.mr_json["milestone"].nil?
|
|
|
|
unless has_milestone
|
|
warn "This merge request does not refer to an existing milestone.", sticky: false
|
|
end
|
|
|
|
has_pick_into_stable_label = gitlab.mr_labels.find { |label| label.start_with?('Pick into') }
|
|
|
|
if gitlab.branch_for_base != "master" && !has_pick_into_stable_label
|
|
warn "Most of the time, merge requests should target `master`. Otherwise, please set the relevant `Pick into X.Y` label."
|
|
end
|
|
|
|
if gitlab.mr_json['title'].length > 72
|
|
warn 'The title of this merge request is longer than 72 characters and ' \
|
|
'would violate our commit message rules when using the Squash on Merge ' \
|
|
'feature. Please consider adjusting the title, or rebase the ' \
|
|
"commits manually and don't use Squash on Merge."
|
|
end
|