diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /lib/gitlab/git_access.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'lib/gitlab/git_access.rb')
-rw-r--r-- | lib/gitlab/git_access.rb | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index b2a65d9f2d8..642a77ced11 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -9,7 +9,6 @@ module Gitlab ForbiddenError = Class.new(StandardError) NotFoundError = Class.new(StandardError) TimeoutError = Class.new(StandardError) - ProjectMovedError = Class.new(NotFoundError) # Use the magic string '_any' to indicate we do not know what the # changes are. This is also what gitlab-shell does. @@ -148,11 +147,11 @@ module Gitlab raise NotFoundError, not_found_message if container.nil? check_project! if project? + add_container_moved_message! end def check_project! check_project_accessibility! - add_project_moved_message! end def check_custom_action @@ -221,12 +220,12 @@ module Gitlab error_message(:project_not_found) end - def add_project_moved_message! + def add_container_moved_message! return if redirected_path.nil? - project_moved = Checks::ProjectMoved.new(repository, user, protocol, redirected_path) + container_moved = Checks::ContainerMoved.new(repository, user, protocol, redirected_path) - project_moved.add_message + container_moved.add_message end def check_command_disabled! @@ -499,13 +498,23 @@ module Gitlab end def check_changes_size - changes_size = 0 + changes_size = + if Feature.enabled?(:git_access_batched_changes_size, project, default_enabled: :yaml) + revs = ['--not', '--all', '--not'] + revs += changes_list.map { |change| change[:newrev] } - changes_list.each do |change| - changes_size += repository.new_blobs(change[:newrev]).sum(&:size) + repository.blobs(revs).sum(&:size) + else + changes_size = 0 - check_size_against_limit(changes_size) - end + changes_list.each do |change| + changes_size += repository.new_blobs(change[:newrev]).sum(&:size) + end + + changes_size + end + + check_size_against_limit(changes_size) end def check_size_against_limit(size) |