Commit 31ae9148 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '7622-fix-push-rules-for-commit-email' into 'master'

Check push rules against commit author for web-based merges

Closes #7622

See merge request gitlab-org/gitlab-ee!7468
parents 08d19660 94cf4c99
...@@ -31,8 +31,8 @@ module EE ...@@ -31,8 +31,8 @@ module EE
return false return false
end end
unless push_rule.author_email_allowed?(current_user.email) unless push_rule.author_email_allowed?(current_user.commit_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) 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 return false
end end
......
...@@ -81,6 +81,12 @@ describe MergeRequests::MergeService do ...@@ -81,6 +81,12 @@ describe MergeRequests::MergeService do
expect(service.hooks_validation_pass?(merge_request)).to be_falsey expect(service.hooks_validation_pass?(merge_request)).to be_falsey
expect(merge_request.merge_error).not_to be_empty expect(merge_request.merge_error).not_to be_empty
end 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 end
context 'fast forward merge request' do 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