Commit 7d9fddca authored by Nick Thomas's avatar Nick Thomas

Fix a bug displaying project commit anchors

A repository can be non-empty, yet lack a root_ref. When this is the
case, we fail to generate a link to commits, resulting in a 500 error.

Using the "default" default branch in this case allows us to generate a
link. It leads to a location that will 404, but that's a better outcome
than the current scenario.

Changelog: fixed
parent 6da49550
......@@ -210,7 +210,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
strong_start: '<strong class="project-stat-value">'.html_safe,
strong_end: '</strong>'.html_safe
},
empty_repo? ? nil : project_commits_path(project, repository.root_ref))
empty_repo? ? nil : project_commits_path(project, default_branch_or_main))
end
def branches_anchor_data
......
---
title: Fix a bug displaying project commit anchors
merge_request: 61361
author:
type: fixed
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