summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2018-06-05 15:04:18 +0000
committerRobert Speicher <robert@gitlab.com>2018-06-05 15:04:18 +0000
commit6ced2f124355ac08b111b4c2ac60ae57e3851ba4 (patch)
tree53f92c7f7766f9c0384ea507d812ce5e7d421b99 /app/models
parentcb77087246929cc92f6bd7ce2cb306855b6e6219 (diff)
parent0d44f4d50ef175997fe1f90de9e622a4f3b867e3 (diff)
downloadgitlab-ce-6ced2f124355ac08b111b4c2ac60ae57e3851ba4.tar.gz
Merge branch '42751-rename-mr-maintainer-push' into 'master'
Rephrase Merge Request Maintainer Edit See merge request gitlab-org/gitlab-ce!19061
Diffstat (limited to 'app/models')
-rw-r--r--app/models/merge_request.rb12
-rw-r--r--app/models/project.rb14
2 files changed, 13 insertions, 13 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 4c1628d2bdb..535a2c362f2 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -1125,21 +1125,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 a094dbcb747..e17eabbb174 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1968,18 +1968,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
@@ -2121,18 +2121,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