summaryrefslogtreecommitdiff
path: root/lib/gitlab/checks/change_access.rb
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2018-02-15 05:21:17 +0000
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2018-02-16 16:26:01 +0000
commitd4d4140c17e409b3a41824e3888427aec80afebf (patch)
tree1f55ac4502b059ca73434dccdeff85e283e8e90d /lib/gitlab/checks/change_access.rb
parentf7c662c733a2a24c044c1f0bad03cfc63f704258 (diff)
downloadgitlab-ce-d4d4140c17e409b3a41824e3888427aec80afebf.tar.gz
Avoid slow File Lock checks when not usedjej/avoid-slow-file-lock-checks
Also avoid double commit lookup during file lock check by reusing memoized commits.
Diffstat (limited to 'lib/gitlab/checks/change_access.rb')
-rw-r--r--lib/gitlab/checks/change_access.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/gitlab/checks/change_access.rb b/lib/gitlab/checks/change_access.rb
index d75e73dac10..94d45c17ca0 100644
--- a/lib/gitlab/checks/change_access.rb
+++ b/lib/gitlab/checks/change_access.rb
@@ -120,6 +120,7 @@ module Gitlab
def commits_check
return if deletion? || newrev.nil?
+ return unless should_run_commit_validations?
# n+1: https://gitlab.com/gitlab-org/gitlab-ee/issues/3593
::Gitlab::GitalyClient.allow_n_plus_1_calls do
@@ -138,6 +139,10 @@ module Gitlab
private
+ def should_run_commit_validations?
+ commit_check.validate_lfs_file_locks?
+ end
+
def updated_from_web?
protocol == 'web'
end
@@ -175,7 +180,7 @@ module Gitlab
end
def commits
- project.repository.new_commits(newrev)
+ @commits ||= project.repository.new_commits(newrev)
end
end
end