Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2018-12-28 13:44:25 +0300
committerDouwe Maan <douwe@gitlab.com>2018-12-28 13:44:25 +0300
commite9b5b10a454c0ca37cdf3abc1712ee391e9e1647 (patch)
tree59ccf5dc3e2bce59a503bf5a9d01141de6c55b6f /lib/gitlab/checks
parentcf200b64d8f4aa70a97b9d1b672a93e813587630 (diff)
Skip per-commit validations which have already passed on another change/branch
Diffstat (limited to 'lib/gitlab/checks')
-rw-r--r--lib/gitlab/checks/base_checker.rb16
-rw-r--r--lib/gitlab/checks/diff_check.rb24
-rw-r--r--lib/gitlab/checks/lfs_check.rb1
3 files changed, 28 insertions, 13 deletions
diff --git a/lib/gitlab/checks/base_checker.rb b/lib/gitlab/checks/base_checker.rb
index f8cda0382fe..7fbcf6a4ff4 100644
--- a/lib/gitlab/checks/base_checker.rb
+++ b/lib/gitlab/checks/base_checker.rb
@@ -33,6 +33,22 @@ module Gitlab
def tag_exists?
project.repository.tag_exists?(tag_name)
end
+
+ def validate_once(resource)
+ Gitlab::SafeRequestStore.fetch(cache_key_for_resource(resource)) do
+ yield(resource)
+
+ true
+ end
+ end
+
+ def cache_key_for_resource(resource)
+ "git_access:#{checker_cache_key}:#{resource.cache_key}"
+ end
+
+ def checker_cache_key
+ self.class.name.demodulize.underscore
+ end
end
end
end
diff --git a/lib/gitlab/checks/diff_check.rb b/lib/gitlab/checks/diff_check.rb
index 8ee345ab45a..63da9a3d6b5 100644
--- a/lib/gitlab/checks/diff_check.rb
+++ b/lib/gitlab/checks/diff_check.rb
@@ -14,13 +14,17 @@ module Gitlab
return if deletion? || newrev.nil?
return unless should_run_diff_validations?
return if commits.empty?
- return unless uses_raw_delta_validations?
file_paths = []
- process_raw_deltas do |diff|
- file_paths << (diff.new_path || diff.old_path)
- validate_diff(diff)
+ process_commits do |commit|
+ validate_once(commit) do
+ commit.raw_deltas.each do |diff|
+ file_paths << (diff.new_path || diff.old_path)
+
+ validate_diff(diff)
+ end
+ end
end
validate_file_paths(file_paths)
@@ -28,17 +32,13 @@ module Gitlab
private
- def should_run_diff_validations?
- validate_lfs_file_locks?
- end
-
def validate_lfs_file_locks?
strong_memoize(:validate_lfs_file_locks) do
project.lfs_enabled? && project.any_lfs_file_locks?
end
end
- def uses_raw_delta_validations?
+ def should_run_diff_validations?
validations_for_diff.present? || path_validations.present?
end
@@ -59,16 +59,14 @@ module Gitlab
validate_lfs_file_locks? ? [lfs_file_locks_validation] : []
end
- def process_raw_deltas
+ def process_commits
logger.log_timed(LOG_MESSAGES[:diff_content_check]) do
# n+1: https://gitlab.com/gitlab-org/gitlab-ee/issues/3593
::Gitlab::GitalyClient.allow_n_plus_1_calls do
commits.each do |commit|
logger.check_timeout_reached
- commit.raw_deltas.each do |diff|
- yield(diff)
- end
+ yield(commit)
end
end
end
diff --git a/lib/gitlab/checks/lfs_check.rb b/lib/gitlab/checks/lfs_check.rb
index e42684e679a..cc6a14d2d9a 100644
--- a/lib/gitlab/checks/lfs_check.rb
+++ b/lib/gitlab/checks/lfs_check.rb
@@ -7,6 +7,7 @@ module Gitlab
ERROR_MESSAGE = 'LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all".'.freeze
def validate!
+ return unless project.lfs_enabled?
return if skip_lfs_integrity_check
logger.log_timed(LOG_MESSAGE) do