diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-07-07 11:36:01 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-07-13 13:24:56 +0530 |
commit | ea9e8f4609f46f9c5713a8346f91dc19d310c2e1 (patch) | |
tree | 6406dec33726bdd99011c7c24920d8020b32027e /lib | |
parent | 4d00ed21ebbc9fd4a1f1b13cbed9a0a9ad2a2a9e (diff) | |
download | gitlab-ce-ea9e8f4609f46f9c5713a8346f91dc19d310c2e1.tar.gz |
Move all "checks" under `GitLab::Checks`.
- https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4892#note_12892160
- This is more consistent.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/checks/change_access.rb (renamed from lib/gitlab/git_access/change_access_check.rb) | 8 | ||||
-rw-r--r-- | lib/gitlab/checks/force_push.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/force_push_check.rb | 15 | ||||
-rw-r--r-- | lib/gitlab/git_access.rb | 2 |
4 files changed, 21 insertions, 21 deletions
diff --git a/lib/gitlab/git_access/change_access_check.rb b/lib/gitlab/checks/change_access.rb index 9268da4ec6e..cb8f4f2cbdd 100644 --- a/lib/gitlab/git_access/change_access_check.rb +++ b/lib/gitlab/checks/change_access.rb @@ -1,6 +1,6 @@ module Gitlab - class GitAccess - class ChangeAccessCheck + module Checks + class ChangeAccess attr_reader :user_access, :project def initialize(change, user_access:, project:) @@ -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) @@ -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? diff --git a/lib/gitlab/checks/force_push.rb b/lib/gitlab/checks/force_push.rb new file mode 100644 index 00000000000..dfa83a0eab3 --- /dev/null +++ b/lib/gitlab/checks/force_push.rb @@ -0,0 +1,17 @@ +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 diff --git a/lib/gitlab/force_push_check.rb b/lib/gitlab/force_push_check.rb deleted file mode 100644 index 93c6a5bb7f5..00000000000 --- a/lib/gitlab/force_push_check.rb +++ /dev/null @@ -1,15 +0,0 @@ -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 diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 9f5bb9d62cd..308f23bc9bc 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -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? |