diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /lib/gitlab/checks | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) | |
download | gitlab-ce-0653e08efd039a5905f3fa4f6e9cef9f5d2f799c.tar.gz |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'lib/gitlab/checks')
-rw-r--r-- | lib/gitlab/checks/base_single_checker.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/checks/changes_access.rb | 38 |
2 files changed, 25 insertions, 15 deletions
diff --git a/lib/gitlab/checks/base_single_checker.rb b/lib/gitlab/checks/base_single_checker.rb index f93902055c9..06519833d7c 100644 --- a/lib/gitlab/checks/base_single_checker.rb +++ b/lib/gitlab/checks/base_single_checker.rb @@ -30,5 +30,3 @@ module Gitlab end end end - -Gitlab::Checks::BaseSingleChecker.prepend_mod_with('Gitlab::Checks::BaseSingleChecker') diff --git a/lib/gitlab/checks/changes_access.rb b/lib/gitlab/checks/changes_access.rb index 9ecc93f871b..3ce2e50c548 100644 --- a/lib/gitlab/checks/changes_access.rb +++ b/lib/gitlab/checks/changes_access.rb @@ -76,23 +76,33 @@ module Gitlab result end + def single_change_accesses + @single_changes_accesses ||= + changes.map do |change| + commits = + if change[:newrev].blank? || Gitlab::Git.blank_ref?(change[:newrev]) + [] + else + Gitlab::Lazy.new { commits_for(change[:newrev]) } + end + + Checks::SingleChangeAccess.new( + change, + user_access: user_access, + project: project, + protocol: protocol, + logger: logger, + commits: commits + ) + end + end + protected def single_access_checks! # Iterate over all changes to find if user allowed all of them to be applied - changes.each do |change| - commits = Gitlab::Lazy.new { commits_for(change[:newrev]) } if Feature.enabled?(:changes_batch_commits) - - # If user does not have access to make at least one change, cancel all - # push by allowing the exception to bubble up - Checks::SingleChangeAccess.new( - change, - user_access: user_access, - project: project, - protocol: protocol, - logger: logger, - commits: commits - ).validate! + single_change_accesses.each do |single_change_access| + single_change_access.validate! end end @@ -102,3 +112,5 @@ module Gitlab end end end + +Gitlab::Checks::ChangesAccess.prepend_mod_with('Gitlab::Checks::ChangesAccess') |