Commit e8c06f42 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'bug/git_hooks' into 'master'

Fix fast-forward merge requests git hooks validations

Current implementations checks git hooks during merge request action issued by Web UI to prevent a git merge action failing and not reporting back to the UI (introduced by !326).
The problem is that we shouldn't make the check the merge commit when we are using a Fast Forward merge type.

Fixes gitlab-org/gitlab-ee#598

See merge request !427
parents 5a688e4f 40172d28
......@@ -9,7 +9,7 @@ module MergeRequests
attr_reader :merge_request
def execute(merge_request)
if @project.merge_requests_ff_only_enabled && !self.is_a?(FfMergeService)
if project.merge_requests_ff_only_enabled && !self.is_a?(FfMergeService)
FfMergeService.new(project, current_user, params).execute(merge_request)
return
end
......@@ -29,6 +29,8 @@ module MergeRequests
end
def hooks_validation_pass?(merge_request)
return true if project.merge_requests_ff_only_enabled
git_hook = merge_request.project.git_hook
return true unless git_hook
......
......@@ -96,5 +96,13 @@ describe MergeRequests::MergeService, services: true do
expect(merge_request.merge_error).not_to be_empty
end
end
context 'fast forward merge request' do
it 'returns true when fast forward is enabled' do
allow(project).to receive(:merge_requests_ff_only_enabled) { true }
expect(service.hooks_validation_pass?(merge_request)).to be_truthy
end
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