This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

Commit f4dac8a5 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira
Browse files

Move can_current_user_push_to_branch to Presenter

parent 52279db9dbe2
...@@ -55,7 +55,9 @@ def can_edit_tree?(project = nil, ref = nil) ...@@ -55,7 +55,9 @@ def can_edit_tree?(project = nil, ref = nil)
def tree_edit_branch(project = @project, ref = @ref) def tree_edit_branch(project = @project, ref = @ref)
return unless can_edit_tree?(project, ref) return unless can_edit_tree?(project, ref)
if project.user_can_push_to_branch?(current_user, ref) project = project.present(current_user: current_user)
if project.can_current_user_push_to_branch?(ref)
ref ref
else else
project = tree_edit_project(project) project = tree_edit_project(project)
......
...@@ -1040,12 +1040,6 @@ def user_can_push_to_empty_repo?(user) ...@@ -1040,12 +1040,6 @@ def user_can_push_to_empty_repo?(user)
!ProtectedBranch.default_branch_protected? || team.max_member_access(user.id) > Gitlab::Access::DEVELOPER !ProtectedBranch.default_branch_protected? || team.max_member_access(user.id) > Gitlab::Access::DEVELOPER
end end
def user_can_push_to_branch?(user, branch_name)
return false unless repository.branch_exists?(branch_name)
::Gitlab::UserAccess.new(user, project: self).can_push_to_branch?(branch_name)
end
def forked? def forked?
return true if fork_network && fork_network.root_project != self return true if fork_network && fork_network.root_project != self
......
...@@ -164,11 +164,17 @@ def can_current_user_push_code? ...@@ -164,11 +164,17 @@ def can_current_user_push_code?
if empty_repo? if empty_repo?
can?(current_user, :push_code, project) can?(current_user, :push_code, project)
else else
user_can_push_to_branch?(current_user, default_branch) can_current_user_push_to_branch?(default_branch)
end end
end end
end end
def can_current_user_push_to_branch?(branch)
return false unless repository.branch_exists?(branch)
::Gitlab::UserAccess.new(current_user, project: project).can_push_to_branch?(branch)
end
def files_anchor_data def files_anchor_data
OpenStruct.new(enabled: true, OpenStruct.new(enabled: true,
label: _('Files (%{human_size})') % { human_size: storage_counter(statistics.total_repository_size) }, label: _('Files (%{human_size})') % { human_size: storage_counter(statistics.total_repository_size) },
......
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