diff options
author | Valery Sizov <valery@gitlab.com> | 2015-01-21 02:23:37 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-01-21 04:34:23 +0300 |
commit | ab7a79bf3bb47fd1c9d82da0bb29a3cdf0246cdc (patch) | |
tree | 7a32b98b19476c6ca633f9cb907f3f9c6e1f6bb8 /lib/gitlab/git_access.rb | |
parent | 148740cc6769b0faf7ee564552143ccd0a18768b (diff) |
developer can push to protected branches
Diffstat (limited to 'lib/gitlab/git_access.rb')
-rw-r--r-- | lib/gitlab/git_access.rb | 9 |
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 |