[rubygems/rubygems] Save array allocation for every dependency in Gemfile

Only need to check for lack of git key when branch option is present

https://github.com/rubygems/rubygems/commit/ebfca1b389
This commit is contained in:
Samuel Giddins 2023-12-14 10:11:42 +08:00 коммит произвёл git
Родитель ca7f7c0f51
Коммит 1cd4b59e8c
1 изменённых файлов: 2 добавлений и 4 удалений

Просмотреть файл

@ -404,13 +404,11 @@ module Bundler
end
def validate_keys(command, opts, valid_keys)
invalid_keys = opts.keys - valid_keys
git_source = opts.keys & @git_sources.keys.map(&:to_s)
if opts["branch"] && !(opts["git"] || opts["github"] || git_source.any?)
if opts["branch"] && !(opts["git"] || opts["github"] || (opts.keys & @git_sources.keys.map(&:to_s)).any?)
raise GemfileError, %(The `branch` option for `#{command}` is not allowed. Only gems with a git source can specify a branch)
end
invalid_keys = opts.keys - valid_keys
return true unless invalid_keys.any?
message = String.new