Fixed developers_can_push in RepoBranch API entity
This commit is contained in:
parent
d5acb69e11
commit
90c8bb8301
2 changed files with 8 additions and 6 deletions
|
@ -14,6 +14,12 @@ module ProtectedRef
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.developers_can?(action, ref)
|
||||||
|
access_levels_for_ref(ref, action: action).any? do |access_level|
|
||||||
|
access_level.access_level == Gitlab::Access::DEVELOPER
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.access_levels_for_ref(ref, action: :push)
|
def self.access_levels_for_ref(ref, action: :push)
|
||||||
self.matching(ref).map(&:"#{action}_access_levels").flatten
|
self.matching(ref).map(&:"#{action}_access_levels").flatten
|
||||||
end
|
end
|
||||||
|
|
|
@ -188,15 +188,11 @@ module API
|
||||||
end
|
end
|
||||||
|
|
||||||
expose :developers_can_push do |repo_branch, options|
|
expose :developers_can_push do |repo_branch, options|
|
||||||
project = options[:project]
|
options[:project].protected_branches.developers_can?(:push, repo_branch.name)
|
||||||
access_levels = project.protected_branches.access_levels_for_ref(repo_branch.name, :push)
|
|
||||||
access_levels.any? { |access_level| access_level.access_level == Gitlab::Access::DEVELOPER }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
expose :developers_can_merge do |repo_branch, options|
|
expose :developers_can_merge do |repo_branch, options|
|
||||||
project = options[:project]
|
options[:project].protected_branches.developers_can?(:merge, repo_branch.name)
|
||||||
access_levels = project.protected_branches.access_levels_for_ref(repo_branch.name, :merge)
|
|
||||||
access_levels.any? { |access_level| access_level.access_level == Gitlab::Access::DEVELOPER }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue