2021-02-12 07:09:02 -05:00
# frozen_string_literal: true
2018-05-21 12:41:21 -04:00
# rubocop:disable Style/SignalException
2022-03-29 11:09:53 -04:00
default_branch = ENV [ 'CI_DEFAULT_BRANCH' ] || 'main'
2021-08-20 14:12:04 -04:00
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
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?
2022-03-29 11:09:53 -04:00
unless has_milestone || ( helper . security_mr? && helper . mr_target_branch == default_branch )
2018-05-21 12:41:21 -04:00
warn " This merge request does not refer to an existing milestone. " , sticky : false
end
2022-03-23 20:07:27 -04:00
has_pick_into_stable_label = helper . mr_labels . find { | label | label . start_with? ( 'Pick into' ) }
2018-05-21 12:41:21 -04:00
2022-03-29 11:09:53 -04:00
if helper . mr_target_branch != 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