Draft: fix: branch selector missing icon
Relates to issue #574489
Changes
This merge request fixes the missing branch selector icon in the repository tree view when accessing URLs without an explicit ref_type parameter.
Modified File
app/controllers/projects/tree_controller.rb
Key Changes
-
Updated
showmethod (line 38)- Changed
@ref_type = ref_typeto@ref_type = ref_type || infer_ref_type - Ensures automatic ref_type inference when not provided in URL parameters
- Changed
-
Added
infer_ref_typeprivate method (lines 97-102)- Leverages existing
ExtractsRef::RequestedRefclass to determine reference type - Returns 'heads' for branches, 'tags' for tags, or nil for commits
- Provides the frontend with necessary information to display the correct icon
- Leverages existing
Problem Solved
Before: URLs like https://gitlab.com/gitlab-org/gitlab/-/tree/master resulted in @ref_type being nil, preventing the frontend from displaying the branch icon.
After: The controller automatically infers the ref_type, enabling proper icon display for branches, tags, and commits even when the parameter is not explicitly provided in the URL.
Edited by Joe Woodward