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

  1. Updated show method (line 38)

    • Changed @ref_type = ref_type to @ref_type = ref_type || infer_ref_type
    • Ensures automatic ref_type inference when not provided in URL parameters
  2. Added infer_ref_type private method (lines 97-102)

    • Leverages existing ExtractsRef::RequestedRef class 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

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

Merge request reports

Loading