debian-mirror-gitlab/danger/z_metadata/Dangerfile

40 lines
1.3 KiB
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
2018-11-18 11:00:15 +05:30
# rubocop:disable Style/SignalException
2021-11-11 11:23:49 +05:30
DEFAULT_BRANCH = 'master'
2021-12-11 22:18:48 +05:30
TYPE_LABELS = [
'type::feature',
2020-07-28 23:09:34 +05:30
'feature::addition',
2021-12-11 22:18:48 +05:30
'type::maintenance',
'type::tooling',
2020-07-28 23:09:34 +05:30
'tooling::pipelines',
'tooling::workflow',
2021-12-11 22:18:48 +05:30
'type::bug'
2019-09-30 21:07:59 +05:30
].freeze
2018-11-18 11:00:15 +05:30
if gitlab.mr_body.size < 5
fail "Please provide a proper merge request description."
end
2021-12-11 22:18:48 +05:30
if (TYPE_LABELS & (gitlab.mr_labels + project_helper.labels_to_add)).empty?
2021-10-27 15:23:28 +05:30
warn 'Please add a [merge request type](https://about.gitlab.com/handbook/engineering/metrics/#work-type-classification) to this merge request.'
2019-09-30 21:07:59 +05:30
end
2018-11-18 11:00:15 +05:30
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-11-11 11:23:49 +05:30
unless has_milestone || (helper.security_mr? && gitlab.branch_for_base == DEFAULT_BRANCH)
2018-11-18 11:00:15 +05:30
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-11-11 11:23:49 +05:30
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-11-18 11:00:15 +05:30
end