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:
authorValery Sizov <valery@gitlab.com>2015-01-21 02:23:37 +0300
committerValery Sizov <valery@gitlab.com>2015-01-21 04:34:23 +0300
commitab7a79bf3bb47fd1c9d82da0bb29a3cdf0246cdc (patch)
tree7a32b98b19476c6ca633f9cb907f3f9c6e1f6bb8 /lib/gitlab/git_access.rb
parent148740cc6769b0faf7ee564552143ccd0a18768b (diff)
developer can push to protected branches
Diffstat (limited to 'lib/gitlab/git_access.rb')
-rw-r--r--lib/gitlab/git_access.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index d47ef61fd11..c7bf2efc628 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -5,6 +5,15 @@ module Gitlab
attr_reader :params, :project, :git_cmd, :user
+ def self.can_push_to_branch?(user, project, ref)
+ if project.protected_branch?(ref) &&
+ !(project.developers_can_push_to_protected_branch?(ref) && project.team.developer?(user))
+ user.can?(:push_code_to_protected_branches, project)
+ else
+ user.can?(:push_code, project)
+ end
+ end
+
def check(actor, cmd, project, changes = nil)
case cmd
when *DOWNLOAD_COMMANDS