2021-02-12 07:09:02 -05:00
# frozen_string_literal: true
2018-05-21 12:41:21 -04:00
# rubocop:disable Style/SignalException
2021-08-20 14:12:04 -04:00
DEFAULT_BRANCH = 'master'
2019-07-11 09:15:34 -04:00
THROUGHPUT_LABELS = [
'Community contribution' ,
'security' ,
'bug' ,
'feature' ,
2020-06-18 11:08:45 -04:00
'feature::addition' ,
'feature::maintenance' ,
'tooling' ,
'tooling::pipelines' ,
'tooling::workflow' ,
2020-03-16 11:09:27 -04:00
'documentation'
2019-07-11 09:15:34 -04:00
] . freeze
2018-05-21 12:41:21 -04:00
if gitlab . mr_body . size < 5
2018-07-10 06:10:54 -04:00
fail " Please provide a proper merge request description. "
2018-05-21 12:41:21 -04:00
end
2019-07-11 09:15:34 -04:00
if ( THROUGHPUT_LABELS & gitlab . mr_labels ) . empty?
2021-08-03 14:10:02 -04:00
warn 'Please add a [merge request type](https://about.gitlab.com/handbook/engineering/metrics/#work-type-classification) to this merge request.'
2019-07-11 09:15:34 -04:00
end
2018-05-21 12:41:21 -04:00
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?
2021-08-20 14:12:04 -04:00
unless has_milestone || ( helper . security_mr? && gitlab . branch_for_base == DEFAULT_BRANCH )
2018-05-21 12:41:21 -04:00
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' ) }
2021-08-20 14:12:04 -04:00
if gitlab . branch_for_base != DEFAULT_BRANCH && ! has_pick_into_stable_label && ! helper . security_mr?
warn " Most of the time, merge requests should target ` #{ DEFAULT_BRANCH } `. Otherwise, please set the relevant `Pick into X.Y` label. "
2018-05-21 12:41:21 -04:00
end