Commit 0bdddc87 authored by Patrick Bajao's avatar Patrick Bajao

Add git_push_execute_all_project_hooks flag

This flag is added so the new behavior can be disabled by enabling
it. It's disabled by default.
parent 888ecca4
......@@ -15,10 +15,9 @@ module Git
def process_changes_by_action(ref_type, changes)
changes_by_action = group_changes_by_action(changes)
execute_project_hooks = changes.size <= Gitlab::CurrentSettings.push_event_hooks_limit
changes_by_action.each do |_, changes|
process_changes(ref_type, changes, execute_project_hooks: execute_project_hooks) if changes.any?
process_changes(ref_type, changes, execute_project_hooks: execute_project_hooks?(changes)) if changes.any?
end
end
......@@ -35,6 +34,10 @@ module Git
:pushed
end
def execute_project_hooks?(changes)
(changes.size <= Gitlab::CurrentSettings.push_event_hooks_limit) || Feature.enabled?(:git_push_execute_all_project_hooks, project)
end
def process_changes(ref_type, changes, execute_project_hooks: true)
push_service_class = push_service_class_for(ref_type)
......
......@@ -55,6 +55,11 @@ describe Git::ProcessRefChangesService do
stub_application_setting(push_event_hooks_limit: push_event_hooks_limit)
end
context 'git_push_execute_all_project_hooks is disabled' do
before do
stub_feature_flags(git_push_execute_all_project_hooks: false)
end
it "calls #{push_service_class} with execute_project_hooks set to false" do
expect(push_service_class)
.to receive(:new)
......@@ -66,6 +71,23 @@ describe Git::ProcessRefChangesService do
end
end
context 'git_push_execute_all_project_hooks is enabled' do
before do
stub_feature_flags(git_push_execute_all_project_hooks: true)
end
it "calls #{push_service_class} with execute_project_hooks set to true" do
expect(push_service_class)
.to receive(:new)
.with(project, project.owner, hash_including(execute_project_hooks: true))
.exactly(changes.count).times
.and_return(service)
subject.execute
end
end
end
context 'pipeline creation' do
context 'with valid .gitlab-ci.yml' do
before 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