diff options
author | Mark Chao <mchao@gitlab.com> | 2018-05-23 04:54:57 +0300 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-06-01 08:33:12 +0300 |
commit | 0d44f4d50ef175997fe1f90de9e622a4f3b867e3 (patch) | |
tree | 1a494b42fdc26c700c87f5ce65e5553ed7ab78db /app/models | |
parent | 76c23de3b63503a08a715afb6414596a7a4879d2 (diff) |
Rephrase "maintainer" to more precise "members who can merge to the target branch"
"Maintainer" will be freed to be used for #42751
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/merge_request.rb | 12 | ||||
-rw-r--r-- | app/models/project.rb | 14 |
2 files changed, 13 insertions, 13 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 79fc155fd3c..86437594279 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -1124,21 +1124,21 @@ class MergeRequest < ActiveRecord::Base project.merge_requests.merged.where(author_id: author_id).empty? end - def allow_maintainer_to_push - maintainer_push_possible? && super + def allow_collaboration + collaborative_push_possible? && super end - alias_method :allow_maintainer_to_push?, :allow_maintainer_to_push + alias_method :allow_collaboration?, :allow_collaboration - def maintainer_push_possible? + def collaborative_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? && + def can_allow_collaboration?(user) + collaborative_push_possible? && Ability.allowed?(user, :push_code, source_project) end diff --git a/app/models/project.rb b/app/models/project.rb index e275ac4dc6f..73b808b4cb5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1973,18 +1973,18 @@ class Project < ActiveRecord::Base .limit(1) .select(1) source_of_merge_requests.opened - .where(allow_maintainer_to_push: true) + .where(allow_collaboration: true) .where('EXISTS (?)', developer_access_exists) end - def branch_allows_maintainer_push?(user, branch_name) + def branch_allows_collaboration?(user, branch_name) return false unless user cache_key = "user:#{user.id}:#{branch_name}:branch_allows_push" - memoized_results = strong_memoize(:branch_allows_maintainer_push) do + memoized_results = strong_memoize(:branch_allows_collaboration) do Hash.new do |result, cache_key| - result[cache_key] = fetch_branch_allows_maintainer_push?(user, branch_name) + result[cache_key] = fetch_branch_allows_collaboration?(user, branch_name) end end @@ -2126,18 +2126,18 @@ class Project < ActiveRecord::Base raise ex end - def fetch_branch_allows_maintainer_push?(user, branch_name) + def fetch_branch_allows_collaboration?(user, branch_name) check_access = -> do next false if empty_repo? merge_request = source_of_merge_requests.opened - .where(allow_maintainer_to_push: true) + .where(allow_collaboration: true) .find_by(source_branch: branch_name) merge_request&.can_be_merged_by?(user) end if RequestStore.active? - RequestStore.fetch("project-#{id}:branch-#{branch_name}:user-#{user.id}:branch_allows_maintainer_push") do + RequestStore.fetch("project-#{id}:branch-#{branch_name}:user-#{user.id}:branch_allows_collaboration") do check_access.call end else |