Fix wiki version_id leaking into sidebar repository link

What does this MR do and why?

Viewing a wiki page version sets @ref to the wiki commit SHA. The sidebar uses this value to build the Repository link, but the SHA only exists in the wiki repository, not the project repository. Clicking Code → Repository therefore leads to a 404. This MR falls back to the root ref in current_ref when @wiki is set, so sidebar links always point to a valid project ref.

Closes #590086 (closed)

Screenshots or screen recordings

Before After
image image

How to set up and validate locally

  1. Create a project with a wiki page
  2. Edit the wiki page to create a second version
  3. Go to Page history and click on an older version
  4. Click Code → Repository in the left sidebar
  5. Before: 404 error (URL contains wiki commit SHA as ref)
  6. After: Repository page loads correctly on the default branch

MR acceptance checklist

  • This MR addresses an existing issue
  • Tests pass locally (bundle exec rspec spec/helpers/projects_helper_spec.rb)

Merge request reports

Loading