Commit 0b0892e7 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'rs-danger-changelog' into 'master'

Loosen Danger requirements for security MRs

See merge request gitlab-org/gitlab!22396
parents 5278996c efc7ed11
......@@ -26,7 +26,7 @@ def check_changelog(path)
fail "`title` should be set, in #{gitlab.html_link(path)}! #{SEE_DOC}" if yaml["title"].nil?
fail "`type` should be set, in #{gitlab.html_link(path)}! #{SEE_DOC}" if yaml["type"].nil?
if yaml["merge_request"].nil?
if yaml["merge_request"].nil? && !helper.security_mr?
message "Consider setting `merge_request` to #{gitlab.mr_json["iid"]} in #{gitlab.html_link(path)}. #{SEE_DOC}"
elsif yaml["merge_request"] != gitlab.mr_json["iid"] && !changelog.ce_port_changelog?(path)
fail "Merge request ID was not set to #{gitlab.mr_json["iid"]}! #{SEE_DOC}"
......
......@@ -32,7 +32,7 @@ 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
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
......
......@@ -174,6 +174,12 @@ module Gitlab
labels - current_mr_labels
end
def security_mr?
return false unless gitlab_helper
gitlab_helper.mr_json['web_url'].include?('/gitlab-org/security/')
end
private
def has_database_scoped_labels?(current_mr_labels)
......
......@@ -34,6 +34,7 @@ describe Gitlab::Danger::Changelog do
{ docs: nil, none: nil }
].each do |categories|
let(:changes_by_category) { categories }
it "is falsy when categories don't require a changelog" do
is_expected.to be_falsy
end
......
......@@ -312,4 +312,26 @@ describe Gitlab::Danger::Helper do
it { is_expected.to match_array(['database', 'database::review pending']) }
end
end
describe '#security_mr?' do
it 'returns false when `gitlab_helper` is unavailable' do
expect(helper).to receive(:gitlab_helper).and_return(nil)
expect(helper).not_to be_security_mr
end
it 'returns false when on a normal merge request' do
expect(fake_gitlab).to receive(:mr_json)
.and_return('web_url' => 'https://gitlab.com/gitlab-org/gitlab/merge_requests/1')
expect(helper).not_to be_security_mr
end
it 'returns true when on a security merge request' do
expect(fake_gitlab).to receive(:mr_json)
.and_return('web_url' => 'https://gitlab.com/gitlab-org/security/gitlab/merge_requests/1')
expect(helper).to be_security_mr
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment