BigW Consortium Gitlab

Commit 90c8bb83 by James Edwards-Jones

Fixed developers_can_push in RepoBranch API entity

parent d5acb69e
...@@ -14,6 +14,12 @@ module ProtectedRef ...@@ -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 ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment