Commit 94cf4c99 authored by Nick Thomas's avatar Nick Thomas

Check push rules against commit author for web-based merges

parent c145774a
......@@ -31,8 +31,8 @@ module EE
return false
end
unless push_rule.author_email_allowed?(current_user.email)
handle_merge_error(log_message: "Commit author's email '#{current_user.email}' does not follow the pattern '#{push_rule.author_email_regex}'", save_message_on_model: true)
unless push_rule.author_email_allowed?(current_user.commit_email)
handle_merge_error(log_message: "Commit author's email '#{current_user.commit_email}' does not follow the pattern '#{push_rule.author_email_regex}'", save_message_on_model: true)
return false
end
......
......@@ -81,6 +81,12 @@ describe MergeRequests::MergeService do
expect(service.hooks_validation_pass?(merge_request)).to be_falsey
expect(merge_request.merge_error).not_to be_empty
end
it 'validates against the commit email' do
user.commit_email = 'foo@unmatchedemaildomain.com'
expect(service.hooks_validation_pass?(merge_request)).to be_truthy
end
end
context 'fast forward merge request' do
......
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