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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-26 15:10:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-26 15:10:28 +0300
commit6a0a4a80f740ccde8a1b4c6c757cb77286e0eec9 (patch)
tree673b9a5a8461b9be27efd02427fd9e4df2a39c6f /lib/gitlab/checks
parentc8a7e4ada117b968f841c2bb300fadc421cb3e98 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/checks')
-rw-r--r--lib/gitlab/checks/base_single_checker.rb2
-rw-r--r--lib/gitlab/checks/changes_access.rb38
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 abc5fca9eee..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 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')