Commit fc7e6ba9 authored by James Lopez's avatar James Lopez

Merge branch 'sh-fix-issue-57067' into 'master'

Disable commit checks when no push rules are active

Closes gitlab-ce#57067

See merge request gitlab-org/gitlab-ee!9569
parents 3bba97f6 7fad50ba
---
title: Disable commit checks when no push rules are active
merge_request: 9569
author:
type: performance
...@@ -9,11 +9,6 @@ module EE ...@@ -9,11 +9,6 @@ module EE
private private
override :should_run_diff_validations?
def should_run_diff_validations?
super || validate_path_locks? || push_rule_checks_commit?
end
def validate_path_locks? def validate_path_locks?
strong_memoize(:validate_path_locks) do strong_memoize(:validate_path_locks) do
project.feature_available?(:file_locks) && project.feature_available?(:file_locks) &&
...@@ -32,7 +27,7 @@ module EE ...@@ -32,7 +27,7 @@ module EE
def validations_for_diff def validations_for_diff
super.tap do |validations| super.tap do |validations|
validations.push(path_locks_validation) if validate_path_locks? validations.push(path_locks_validation) if validate_path_locks?
validations.push(file_name_validation) if push_rule validations.push(file_name_validation) if push_rule_checks_commit?
end end
end end
......
...@@ -6,6 +6,16 @@ describe Gitlab::Checks::DiffCheck do ...@@ -6,6 +6,16 @@ describe Gitlab::Checks::DiffCheck do
include_context 'push rules checks context' include_context 'push rules checks context'
describe '#validate!' do describe '#validate!' do
context 'no push rules active' do
set(:push_rule) { create(:push_rule) }
it "does not attempt to check commits" do
expect(subject).not_to receive(:process_commits)
subject.validate!
end
end
context 'file name rules' do context 'file name rules' do
# Notice that the commit used creates a file named 'README' # Notice that the commit used creates a file named 'README'
context 'file name regex check' do context 'file name regex check' 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