2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
class BranchesFinder < GitRefsFinder
|
2018-03-27 19:54:05 +05:30
|
|
|
def initialize(repository, params = {})
|
2019-12-26 22:10:19 +05:30
|
|
|
super(repository, params)
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2018-12-13 13:39:08 +05:30
|
|
|
branches = repository.branches_sorted_by(sort)
|
|
|
|
branches = by_search(branches)
|
2019-09-30 21:07:59 +05:30
|
|
|
branches = by_names(branches)
|
2018-12-13 13:39:08 +05:30
|
|
|
branches
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
def names
|
|
|
|
@params[:names].presence
|
|
|
|
end
|
|
|
|
|
|
|
|
def by_names(branches)
|
|
|
|
return branches unless names
|
|
|
|
|
|
|
|
branch_names = names.to_set
|
2019-10-12 21:52:04 +05:30
|
|
|
branches.select do |branch|
|
2019-09-30 21:07:59 +05:30
|
|
|
branch_names.include?(branch.name)
|
|
|
|
end
|
|
|
|
end
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|