gitlab-org--gitlab-foss/danger/metadata/Dangerfile

41 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
# rubocop:disable Style/SignalException
2019-07-11 09:15:34 -04:00
THROUGHPUT_LABELS = [
'Community contribution',
'security',
'bug',
'feature',
'feature::addition',
'feature::maintenance',
'tooling',
'tooling::pipelines',
'tooling::workflow',
'documentation'
2019-07-11 09:15:34 -04:00
].freeze
if gitlab.mr_body.size < 5
fail "Please provide a proper merge request description."
end
2019-07-11 09:15:34 -04:00
if (THROUGHPUT_LABELS & gitlab.mr_labels).empty?
warn 'Please add a [throughput label](https://about.gitlab.com/handbook/engineering/metrics/#data-classification) to this merge request.'
2019-07-11 09:15:34 -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?
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 && !helper.security_mr?
warn "Most of the time, merge requests should target `master`. Otherwise, please set the relevant `Pick into X.Y` label."
end