diff --git a/debian/patches/0003-Ruby-3-support-615.patch b/debian/patches/0003-Ruby-3-support-615.patch new file mode 100644 index 0000000..09db91d --- /dev/null +++ b/debian/patches/0003-Ruby-3-support-615.patch @@ -0,0 +1,116 @@ +From: Koen Van der Auwera +Date: Mon, 17 May 2021 17:43:56 +0200 +Subject: Ruby 3 support (#615) + +* Remove warning: instance variable @json_output not initialized + +* Ruby 3 support. + +More specific for method_missing: Keyword arguments are separated from other argument +https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/ + +* Need to remove the original one, duh. + +* Remove trailing whitespace + +* Use normalcase for variable numbers. + +* Prefer single-quoted strings when you don't need string interpolation or special symbols. + +* Do not use parentheses for method calls with no arguments + +* Refactored out use of `eval`. + +* Add empty line after guard clause + +* As suggested, use Gem::Version to compare Ruby version numbers. + +Origin: backport, https://github.com/NARKOZ/gitlab/commit/6fc4203d2e02 +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=996236 +Reviewed-By: Lucas Kanashiro +--- + lib/gitlab.rb | 17 ++++++++++++----- + lib/gitlab/cli.rb | 2 +- + lib/gitlab/help.rb | 10 +++++----- + spec/gitlab/client/build_variables_spec.rb | 2 +- + 4 files changed, 19 insertions(+), 12 deletions(-) + +diff --git a/lib/gitlab.rb b/lib/gitlab.rb +index 0a875bb..b87ba95 100644 +--- a/lib/gitlab.rb ++++ b/lib/gitlab.rb +@@ -21,11 +21,18 @@ module Gitlab + Gitlab::Client.new(options) + end + +- # Delegate to Gitlab::Client +- def self.method_missing(method, *args, &block) +- return super unless client.respond_to?(method) +- +- client.send(method, *args, &block) ++ if Gem::Version.new(RUBY_VERSION).release >= Gem::Version.new('3.0.0') ++ def self.method_missing(method, *args, **keywargs, &block) ++ return super unless client.respond_to?(method) ++ ++ client.send(method, *args, **keywargs, &block) ++ end ++ else ++ def self.method_missing(method, *args, &block) ++ return super unless client.respond_to?(method) ++ ++ client.send(method, *args, &block) ++ end + end + + # Delegate to Gitlab::Client +diff --git a/lib/gitlab/cli.rb b/lib/gitlab/cli.rb +index 5819bff..fb8be25 100644 +--- a/lib/gitlab/cli.rb ++++ b/lib/gitlab/cli.rb +@@ -79,7 +79,7 @@ class Gitlab::CLI + # Helper method that checks whether we want to get the output as json + # @return [nil] + def self.render_output(cmd, args, data) +- if @json_output ++ if defined?(@json_output) && @json_output + output_json(cmd, args, data) + else + output_table(cmd, args, data) +diff --git a/lib/gitlab/help.rb b/lib/gitlab/help.rb +index f7ed37b..5469655 100644 +--- a/lib/gitlab/help.rb ++++ b/lib/gitlab/help.rb +@@ -81,15 +81,15 @@ module Gitlab::Help + # Massage output from 'ri'. + def change_help_output!(cmd, output_str) + output_str = +output_str +- output_str.gsub!(/#{cmd}\((.*?)\)/m, "#{cmd} \1") +- output_str.gsub!(/,\s*/, ' ') ++ output_str.gsub!(/#{cmd}(\(.*?\))/m, "#{cmd}\\1") ++ output_str.gsub!(/,\s*/, ', ') + + # Ensure @option descriptions are on a single line + output_str.gsub!(/\n\[/, " \[") + output_str.gsub!(/\s(@)/, "\n@") +- output_str.gsub!(/(\])\n(:)/, '\1 \2') +- output_str.gsub!(/(:.*)(\n)(.*\.)/, '\1 \3') +- output_str.gsub!(/\{(.+)\}/, '"{\1}"') ++ output_str.gsub!(/(\])\n(:)/, '\\1 \\2') ++ output_str.gsub!(/(:.*)(\n)(.*\.)/, '\\1 \\3') ++ output_str.gsub!(/\{(.+)\}/, '"{\\1}"') + end + end + end +diff --git a/spec/gitlab/client/build_variables_spec.rb b/spec/gitlab/client/build_variables_spec.rb +index 77672f5..d09f8e0 100644 +--- a/spec/gitlab/client/build_variables_spec.rb ++++ b/spec/gitlab/client/build_variables_spec.rb +@@ -38,7 +38,7 @@ describe Gitlab::Client do + + describe '.create_variable' do + before do +- stub_post('/projects/3/variables', 'variable') ++ stub_post('/projects/3/variables', 'variable', { masked: true }) + @variable = Gitlab.create_variable(3, 'NEW_VARIABLE', 'new value') + end + diff --git a/debian/patches/series b/debian/patches/series index a0d7a11..97147c0 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1,3 @@ use-installed-libraries.patch relax-dependency-terminal-table.patch +0003-Ruby-3-support-615.patch