Package list ruby-gitlab / d962a7e
Add patch to support ruby3.0 (Closes: #996236) Lucas Kanashiro 7 months ago
2 changed file(s) with 117 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 From: Koen Van der Auwera <atog@hey.com>
1 Date: Mon, 17 May 2021 17:43:56 +0200
2 Subject: Ruby 3 support (#615)
3
4 * Remove warning: instance variable @json_output not initialized
5
6 * Ruby 3 support.
7
8 More specific for method_missing: Keyword arguments are separated from other argument
9 https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/
10
11 * Need to remove the original one, duh.
12
13 * Remove trailing whitespace
14
15 * Use normalcase for variable numbers.
16
17 * Prefer single-quoted strings when you don't need string interpolation or special symbols.
18
19 * Do not use parentheses for method calls with no arguments
20
21 * Refactored out use of `eval`.
22
23 * Add empty line after guard clause
24
25 * As suggested, use Gem::Version to compare Ruby version numbers.
26
27 Origin: backport, https://github.com/NARKOZ/gitlab/commit/6fc4203d2e02
28 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=996236
29 Reviewed-By: Lucas Kanashiro <kanashiro@debian.org>
30 ---
31 lib/gitlab.rb | 17 ++++++++++++-----
32 lib/gitlab/cli.rb | 2 +-
33 lib/gitlab/help.rb | 10 +++++-----
34 spec/gitlab/client/build_variables_spec.rb | 2 +-
35 4 files changed, 19 insertions(+), 12 deletions(-)
36
37 diff --git a/lib/gitlab.rb b/lib/gitlab.rb
38 index 0a875bb..b87ba95 100644
39 --- a/lib/gitlab.rb
40 +++ b/lib/gitlab.rb
41 @@ -21,11 +21,18 @@ module Gitlab
42 Gitlab::Client.new(options)
43 end
44
45 - # Delegate to Gitlab::Client
46 - def self.method_missing(method, *args, &block)
47 - return super unless client.respond_to?(method)
48 -
49 - client.send(method, *args, &block)
50 + if Gem::Version.new(RUBY_VERSION).release >= Gem::Version.new('3.0.0')
51 + def self.method_missing(method, *args, **keywargs, &block)
52 + return super unless client.respond_to?(method)
53 +
54 + client.send(method, *args, **keywargs, &block)
55 + end
56 + else
57 + def self.method_missing(method, *args, &block)
58 + return super unless client.respond_to?(method)
59 +
60 + client.send(method, *args, &block)
61 + end
62 end
63
64 # Delegate to Gitlab::Client
65 diff --git a/lib/gitlab/cli.rb b/lib/gitlab/cli.rb
66 index 5819bff..fb8be25 100644
67 --- a/lib/gitlab/cli.rb
68 +++ b/lib/gitlab/cli.rb
69 @@ -79,7 +79,7 @@ class Gitlab::CLI
70 # Helper method that checks whether we want to get the output as json
71 # @return [nil]
72 def self.render_output(cmd, args, data)
73 - if @json_output
74 + if defined?(@json_output) && @json_output
75 output_json(cmd, args, data)
76 else
77 output_table(cmd, args, data)
78 diff --git a/lib/gitlab/help.rb b/lib/gitlab/help.rb
79 index f7ed37b..5469655 100644
80 --- a/lib/gitlab/help.rb
81 +++ b/lib/gitlab/help.rb
82 @@ -81,15 +81,15 @@ module Gitlab::Help
83 # Massage output from 'ri'.
84 def change_help_output!(cmd, output_str)
85 output_str = +output_str
86 - output_str.gsub!(/#{cmd}\((.*?)\)/m, "#{cmd} \1")
87 - output_str.gsub!(/,\s*/, ' ')
88 + output_str.gsub!(/#{cmd}(\(.*?\))/m, "#{cmd}\\1")
89 + output_str.gsub!(/,\s*/, ', ')
90
91 # Ensure @option descriptions are on a single line
92 output_str.gsub!(/\n\[/, " \[")
93 output_str.gsub!(/\s(@)/, "\n@")
94 - output_str.gsub!(/(\])\n(:)/, '\1 \2')
95 - output_str.gsub!(/(:.*)(\n)(.*\.)/, '\1 \3')
96 - output_str.gsub!(/\{(.+)\}/, '"{\1}"')
97 + output_str.gsub!(/(\])\n(:)/, '\\1 \\2')
98 + output_str.gsub!(/(:.*)(\n)(.*\.)/, '\\1 \\3')
99 + output_str.gsub!(/\{(.+)\}/, '"{\\1}"')
100 end
101 end
102 end
103 diff --git a/spec/gitlab/client/build_variables_spec.rb b/spec/gitlab/client/build_variables_spec.rb
104 index 77672f5..d09f8e0 100644
105 --- a/spec/gitlab/client/build_variables_spec.rb
106 +++ b/spec/gitlab/client/build_variables_spec.rb
107 @@ -38,7 +38,7 @@ describe Gitlab::Client do
108
109 describe '.create_variable' do
110 before do
111 - stub_post('/projects/3/variables', 'variable')
112 + stub_post('/projects/3/variables', 'variable', { masked: true })
113 @variable = Gitlab.create_variable(3, 'NEW_VARIABLE', 'new value')
114 end
115
00 use-installed-libraries.patch
11 relax-dependency-terminal-table.patch
2 0003-Ruby-3-support-615.patch