Add ref_names parameter support to Gitlab::Git::Finders::RefsFinder
Summary
Add support for filtering by a list of specific branch/tag names in Gitlab::Git::Finders::RefsFinder to match the functionality currently available in BranchesFinder.
Background
As part of the effort to replace BranchesFinder with Gitlab::Git::Finders::RefsFinder (Epic &11057), we need to implement the names parameter functionality that allows filtering refs by providing a specific list of names.
Currently, BranchesFinder supports this via:
BranchesFinder.new(repository, { names: %w[fix csv lfs does-not-exist] }).execute
# Returns only branches named 'fix', 'csv', and 'lfs' (ignoring non-existent ones)
Current Usage in Codebase
The names parameter is used in several places:
-
Branches Controller -
app/controllers/projects/branches_controller.rb:58branches = BranchesFinder.new(repository, params.permit(names: [])).execute -
Branch filtering operations where specific branch names need to be retrieved
Proposed Implementation
Add a ref_names parameter to Gitlab::Git::Finders::RefsFinder that:
- Accepts an array of ref names to filter by
- Returns only matching refs (ignoring non-existent names)
- Maintains current sorting behavior when names are provided
-
Works with both branches and tags (based on
ref_type)
API Design
# New usage pattern
Gitlab::Git::Finders::RefsFinder.new(
repository,
ref_type: :branches,
ref_names: %w[fix csv lfs does-not-exist]
).execute
# Should return only refs for 'fix', 'csv', and 'lfs'
Related
- Parent issue: #578546 (Spike: Replace existing BranchesFinder with Gitlab::Git::Finders::RefsFinder)
- Epic: &11057 (Move branch/tag searching to Gitaly)
- Original RefsFinder MR: !125718 (merged)
Edited by Vasilii Iakliushin