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:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-02-23 20:30:37 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-03-07 17:12:31 +0300
commit792ab0631c85098fbf92e727b77158fb9dae5219 (patch)
tree390bd2b69c2de7f229f4d073ad60282b473312d7 /app/models/merge_request.rb
parent9ba0052cdd5ae12ea6b1edd8d25867e0fef25afc (diff)
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.rb18
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