Fix breadcrumb path for commits page
Summary
The Commits link in the breadcrumb always redirects back to the default branch, which is confusing when viewing a commit in a different branch.
Steps to reproduce
Example Project
Any project with multiple branches and commits.
What is the current bug behavior?
When viewing an individual commit in a specific branch, the breadcrumb option for commits always redirects back to the default branch which is unexpected.
What is the expected correct behavior?
Commits in the breadcrumb path should keep the branch that was selected, not fall back to the default.
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Possible fixes
Investigation opportunities
def commits_root
redirect_to project_commits_path(@project, @project.default_branch)
end
https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/helpers/routing/projects_helper.rb#L9
def project_commits_path(project, ref = nil, *args)
namespace_project_commits_path(project.namespace, project, ref || @ref || project.repository.root_ref, *args) # rubocop:disable Cop/ProjectPathHelper
end