Skip to content
Snippets Groups Projects
Commit ea9e8f46 authored by Timothy Andrew's avatar Timothy Andrew
Browse files

Move all "checks" under `GitLab::Checks`.

parent 4d00ed21
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -48,7 +48,7 @@ module MergeRequests
end
 
def force_push?
Gitlab::ForcePushCheck.force_push?(@project, @oldrev, @newrev)
Gitlab::Checks::ForcePush.force_push?(@project, @oldrev, @newrev)
end
 
# Refresh merge request diff if we push to source or target branch of merge request
Loading
Loading
module Gitlab
class GitAccess
class ChangeAccessCheck
module Checks
class ChangeAccess
attr_reader :user_access, :project
 
def initialize(change, user_access:, project:)
Loading
Loading
@@ -25,8 +25,6 @@ module Gitlab
def protected_branch_checks
return unless project.protected_branch?(@branch_name)
 
return unless project.protected_branch?(@branch_name)
if forced_push? && user_access.cannot_do_action?(:force_push_code_to_protected_branches)
return "You are not allowed to force push code to a protected branch on this project."
elsif Gitlab::Git.blank_ref?(@newrev) && user_access.cannot_do_action?(:remove_protected_branches)
Loading
Loading
@@ -67,7 +65,7 @@ module Gitlab
end
 
def forced_push?
Gitlab::ForcePushCheck.force_push?(@project, @oldrev, @newrev)
Gitlab::Checks::ForcePush.force_push?(@project, @oldrev, @newrev)
end
 
def matching_merge_request?
Loading
Loading
module Gitlab
module Checks
class ForcePush
def self.force_push?(project, oldrev, newrev)
return false if project.empty_repo?
# Created or deleted branch
if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev)
false
else
missed_refs, _ = Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} --git-dir=#{project.repository.path_to_repo} rev-list #{oldrev} ^#{newrev}))
missed_refs.split("\n").size > 0
end
end
end
end
end
module Gitlab
class ForcePushCheck
def self.force_push?(project, oldrev, newrev)
return false if project.empty_repo?
# Created or deleted branch
if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev)
false
else
missed_refs, _ = Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} --git-dir=#{project.repository.path_to_repo} rev-list #{oldrev} ^#{newrev}))
missed_refs.split("\n").size > 0
end
end
end
end
Loading
Loading
@@ -91,7 +91,7 @@ module Gitlab
end
 
def change_access_check(change)
ChangeAccessCheck.new(change, user_access: user_access, project: project).exec
Checks::ChangeAccess.new(change, user_access: user_access, project: project).exec
end
 
def protocol_allowed?
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment