Draft: fix: branch icon missing in repository selector
Relates to issue #574489
Changes
This MR fixes the missing branch/tag icons in the repository selector when visiting repository pages without ref_type in the URL parameters.
Key Changes:
-
lib/extracts_ref/ref_extractor.rb
- Added
inferred_ref_typeto attr_accessor to store the inferred reference type - Modified
extract!method to infer ref_type usingRequestedRefwhenparams[:ref_type]is not provided - The inferred ref_type is stored and used to set the fully qualified ref
- Added
-
lib/extracts_path.rb
- Updated
assign_ref_varsto store@inferred_ref_typefrom ref_extractor - Modified
ref_typemethod to return inferred value as fallback:ExtractsRef::RefExtractor.ref_type(params[:ref_type]) || @inferred_ref_type
- Updated
-
Controllers (Verification)
- Confirmed tree_controller.rb, commits_controller.rb, and blob_controller.rb already have
@ref_type = ref_typewhich will now use the inferred value
- Confirmed tree_controller.rb, commits_controller.rb, and blob_controller.rb already have
Expected Behavior:
When visiting repository pages without ref_type in the URL (e.g., /gitlab-org/gitlab/-/tree/master):
- Backend infers that "master" is a branch → sets
@inferred_ref_type = 'heads' - Backend sets
@fully_qualified_ref = 'refs/heads/master' - Frontend receives
refType='heads'and displays the correct branch icon - Same logic applies for tags →
refType='tags'with tag icon
This ensures consistent icon display across all repository pages, matching the behavior already working on the Commits page.
Edited by Joe Woodward