diff options
Diffstat (limited to 'app/presenters/project_presenter.rb')
-rw-r--r-- | app/presenters/project_presenter.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index f850f6273a3..9db4ef63fd7 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -164,11 +164,17 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated if empty_repo? can?(current_user, :push_code, project) else - user_can_push_to_branch?(current_user, default_branch) + can_current_user_push_to_branch?(default_branch) 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 OpenStruct.new(enabled: true, label: _('Files (%{human_size})') % { human_size: storage_counter(statistics.total_repository_size) }, |