summaryrefslogtreecommitdiff
path: root/danger/z_metadata/Dangerfile
blob: 9140bb7d9886819a813d787f25ea6a181879bc7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

# rubocop:disable Style/SignalException

default_branch = ENV['CI_DEFAULT_BRANCH'] || 'main'

if gitlab.mr_body.size < 5
  fail "Please provide a proper merge request description."
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 || (helper.security_mr? && helper.mr_target_branch == default_branch)
  warn "This merge request does not refer to an existing milestone.", sticky: false
end

has_pick_into_stable_label = helper.mr_labels.find { |label| label.start_with?('Pick into') }

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."
end