diff options
author | Stan Hu <stanhu@gmail.com> | 2020-09-29 23:06:49 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2020-09-30 00:04:59 +0300 |
commit | a214b859b7c9cc1612c9ff02df5f47a8b837b4b0 (patch) | |
tree | cea7a3bc5f8f699567b782711218ef595ffa0981 | |
parent | 657c39709f8ca013e07cc0d126664db7ac745e22 (diff) |
Fix Ruby 2.7 keyword deprecation warnings
See
https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
for more details.
-rw-r--r-- | changelogs/unreleased/sh-fix-ruby-2-7-kwargs-deprecations.yml | 5 | ||||
-rw-r--r-- | ruby/Gemfile.lock | 2 | ||||
-rw-r--r-- | ruby/lib/gitlab/git/lfs_changes.rb | 4 | ||||
-rw-r--r-- | ruby/lib/gitlab/git/rev_list.rb | 8 | ||||
-rw-r--r-- | ruby/spec/lib/gitlab/git/gitlab_projects_spec.rb | 2 | ||||
-rw-r--r-- | ruby/spec/lib/gitlab/git/popen_spec.rb | 2 | ||||
-rw-r--r-- | ruby/spec/lib/gitlab/git/repository_spec.rb | 16 |
7 files changed, 22 insertions, 17 deletions
diff --git a/changelogs/unreleased/sh-fix-ruby-2-7-kwargs-deprecations.yml b/changelogs/unreleased/sh-fix-ruby-2-7-kwargs-deprecations.yml new file mode 100644 index 000000000..f393eb962 --- /dev/null +++ b/changelogs/unreleased/sh-fix-ruby-2-7-kwargs-deprecations.yml @@ -0,0 +1,5 @@ +--- +title: Fix Ruby 2.7 keyword deprecation deprecation warnings +merge_request: 2611 +author: +type: other diff --git a/ruby/Gemfile.lock b/ruby/Gemfile.lock index 399a44330..87b1fc7f5 100644 --- a/ruby/Gemfile.lock +++ b/ruby/Gemfile.lock @@ -90,7 +90,7 @@ GEM opentracing (~> 0.3) thrift jaro_winkler (1.5.2) - json (2.3.1) + json (2.2.0) licensee (8.9.2) rugged (~> 0.24) listen (0.5.3) diff --git a/ruby/lib/gitlab/git/lfs_changes.rb b/ruby/lib/gitlab/git/lfs_changes.rb index 442cd9d2b..194d5f584 100644 --- a/ruby/lib/gitlab/git/lfs_changes.rb +++ b/ruby/lib/gitlab/git/lfs_changes.rb @@ -17,7 +17,7 @@ module Gitlab private def git_new_pointers(object_limit, not_in) - rev_list.new_objects(rev_list_params(not_in: not_in)) do |object_ids| + rev_list.new_objects(**rev_list_params(not_in: not_in)) do |object_ids| object_ids = object_ids.take(object_limit) if object_limit Gitlab::Git::Blob.batch_lfs_pointers(@repository, object_ids) @@ -27,7 +27,7 @@ module Gitlab def git_all_pointers params = { options: ["--filter=blob:limit=#{Gitlab::Git::Blob::LFS_POINTER_MAX_SIZE}"] } - rev_list.all_objects(rev_list_params(params)) do |object_ids| + rev_list.all_objects(**rev_list_params(params)) do |object_ids| Gitlab::Git::Blob.batch_lfs_pointers(@repository, object_ids) end end diff --git a/ruby/lib/gitlab/git/rev_list.rb b/ruby/lib/gitlab/git/rev_list.rb index 5fdad077e..79ba07ae5 100644 --- a/ruby/lib/gitlab/git/rev_list.rb +++ b/ruby/lib/gitlab/git/rev_list.rb @@ -33,7 +33,7 @@ module Gitlab require_path: require_path } - get_objects(opts, &lazy_block) + get_objects(**opts, &lazy_block) end def all_objects(options: [], require_path: nil, &lazy_block) @@ -45,14 +45,14 @@ module Gitlab private - def execute(args) - repository.rev_list(args).split("\n") + def execute(**args) + repository.rev_list(**args).split("\n") end def get_objects(including: [], excluding: [], options: [], require_path: nil) opts = { including: including, excluding: excluding, options: options, objects: true } - repository.rev_list(opts) do |lazy_output| + repository.rev_list(**opts) do |lazy_output| objects = objects_from_output(lazy_output, require_path: require_path) yield(objects) diff --git a/ruby/spec/lib/gitlab/git/gitlab_projects_spec.rb b/ruby/spec/lib/gitlab/git/gitlab_projects_spec.rb index a1ef8b51b..cd1a6c2e4 100644 --- a/ruby/spec/lib/gitlab/git/gitlab_projects_spec.rb +++ b/ruby/spec/lib/gitlab/git/gitlab_projects_spec.rb @@ -106,7 +106,7 @@ describe Gitlab::Git::GitlabProjects do let(:args) { { force: force, tags: tags, env: env, prune: prune } } let(:cmd) { %W(#{Gitlab.config.git.bin_path} -c http.followRedirects=false fetch #{remote_name} --quiet --prune --tags) } - subject { gl_projects.fetch_remote(remote_name, 600, args) } + subject { gl_projects.fetch_remote(remote_name, 600, **args) } context 'with default args' do it 'executes the command' do diff --git a/ruby/spec/lib/gitlab/git/popen_spec.rb b/ruby/spec/lib/gitlab/git/popen_spec.rb index efa3ed922..22739e9c5 100644 --- a/ruby/spec/lib/gitlab/git/popen_spec.rb +++ b/ruby/spec/lib/gitlab/git/popen_spec.rb @@ -61,7 +61,7 @@ describe 'Gitlab::Git::Popen' do it 'calls popen3 with the provided environment variables' do expect(Open3).to receive(:popen3).with(vars, 'ls', options) - klass.new.popen(%w(ls), path, 'foobar' => 123) + klass.new.popen(%w(ls), path, { 'foobar' => 123 }) # rubocop:disable Style/BracesAroundHashParameters: end end diff --git a/ruby/spec/lib/gitlab/git/repository_spec.rb b/ruby/spec/lib/gitlab/git/repository_spec.rb index 9994fc8cc..16c485660 100644 --- a/ruby/spec/lib/gitlab/git/repository_spec.rb +++ b/ruby/spec/lib/gitlab/git/repository_spec.rb @@ -605,15 +605,15 @@ describe Gitlab::Git::Repository do # rubocop:disable Metrics/BlockLength remote_branch: remote_branch } - repository.rebase(user, rebase_id, opts) + repository.rebase(user, rebase_id, **opts) end describe 'sparse checkout' do let(:expected_files) { %w[files/images/emoji.png] } it 'lists files modified in source branch in sparse-checkout' do - allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args| - m.call(*args) do + allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args, **kwargs| + m.call(*args, **kwargs) do worktree = args[0] sparse = repository.path + "/worktrees/#{worktree.name}/info/sparse-checkout" diff_files = IO.readlines(sparse, chomp: true) @@ -641,15 +641,15 @@ describe Gitlab::Git::Repository do # rubocop:disable Metrics/BlockLength message: 'Squash commit message' } - repository.squash(user, squash_id, opts) + repository.squash(user, squash_id, **opts) end describe 'sparse checkout' do let(:expected_files) { %w[files files/js files/js/application.js] } it 'checks out only the files in the diff' do - allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args| - m.call(*args) do + allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args, **kwargs| + m.call(*args, **kwargs) do worktree = args[0] files_pattern = File.join(worktree.path, '**', '*') expected = expected_files.map do |path| @@ -672,8 +672,8 @@ describe Gitlab::Git::Repository do # rubocop:disable Metrics/BlockLength end it 'does not include the renamed file in the sparse checkout' do - allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args| - m.call(*args) do + allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args, **kwargs| + m.call(*args, **kwargs) do worktree = args[0] files_pattern = File.join(worktree.path, '**', '*') |