From 33e10d700fe0fd2884465aea615aea85abdd0be1 Mon Sep 17 00:00:00 2001 From: Daniel Gerhardt Date: Mon, 5 Aug 2019 23:01:53 +0200 Subject: Fix Ruby 2.5 compatibility for diverging counts of branches !31480 does not fully restore compatibility because another Ruby 2.6 feature besides `Enumerable#filter` was used in commit ca5cd7b7. The use of `Enumerable#to_h`'s block is now replaced by an explicit `Enumerable#map` call. Error message: TypeError (wrong element type Gitlab::Git::Branch at 0 (expected array)): app/controllers/projects/branches_controller.rb:53:in `to_h' See https://bugs.ruby-lang.org/issues/15143. Fixes #64143. --- app/controllers/projects/branches_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 141a7dfb923..e7bdb4b2042 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -49,7 +49,7 @@ class Projects::BranchesController < Projects::ApplicationController branches = BranchesFinder.new(repository, params.permit(names: [])).execute Gitlab::GitalyClient.allow_n_plus_1_calls do - render json: branches.to_h { |branch| [branch.name, service.call(branch)] } + render json: branches.map { |branch| [branch.name, service.call(branch)] }.to_h end end end -- cgit v1.2.1