diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-02-23 18:30:37 +0100 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-03-07 15:12:31 +0100 |
commit | 792ab0631c85098fbf92e727b77158fb9dae5219 (patch) | |
tree | 390bd2b69c2de7f229f4d073ad60282b473312d7 /app/models/merge_request.rb | |
parent | 9ba0052cdd5ae12ea6b1edd8d25867e0fef25afc (diff) | |
download | gitlab-ce-792ab0631c85098fbf92e727b77158fb9dae5219.tar.gz |
Allow a user to select `allow maintainer to push`
When a project is not private, and the source branch not protected the
user can now select the option to allow maintainers to push to this
branch
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r-- | app/models/merge_request.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 9a7e66a9cbb..59fd2d4e4a0 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -1087,4 +1087,22 @@ class MergeRequest < ActiveRecord::Base project.merge_requests.merged.where(author_id: author_id).empty? end + + def allow_maintainer_to_push + maintainer_push_possible? && super + end + + alias_method :allow_maintainer_to_push?, :allow_maintainer_to_push + + def maintainer_push_possible? + source_project.present? && for_fork? && + target_project.visibility_level > Gitlab::VisibilityLevel::PRIVATE && + source_project.visibility_level > Gitlab::VisibilityLevel::PRIVATE && + !ProtectedBranch.protected?(source_project, source_branch) + end + + def can_allow_maintainer_to_push?(user) + maintainer_push_possible? && + Ability.allowed?(user, :push_code, source_project) + end end |