Skip to content

Commit 77db078

Browse files
mhoyertit
authored andcommitted
Ruby version compatibility conflict solution
``` $ ruby --version $ irb -r git ``` This warning call because lines 1055 and 1057 have old Ruby syntax. ``` return str.encode(default_encoding, str.encoding, encoding_options) if str.valid_encoding? ``` @see https://piechowski.io/post/last-arg-keyword-deprecated-ruby-2-7/ Signed-off-by: Sergey Blohin <sblohin@yandex.ru>
1 parent c85dd82 commit 77db078

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/git/lib.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,7 @@ def command(cmd, opts = [], chdir = true, redirect = '', &block)
945945
global_opts = []
946946
global_opts << "--git-dir=#{@git_dir}" if !@git_dir.nil?
947947
global_opts << "--work-tree=#{@git_work_dir}" if !@git_work_dir.nil?
948+
global_opts << ["-c", "color.ui=false"]
948949

949950
opts = [opts].flatten.map {|s| escape(s) }.join(' ')
950951

@@ -1051,9 +1052,9 @@ def encoding_options
10511052
def normalize_encoding(str)
10521053
return str if str.valid_encoding? && str.encoding == default_encoding
10531054

1054-
return str.encode(default_encoding, str.encoding, encoding_options) if str.valid_encoding?
1055+
return str.encode(default_encoding, str.encoding, **encoding_options) if str.valid_encoding?
10551056

1056-
str.encode(default_encoding, detected_encoding(str), encoding_options)
1057+
str.encode(default_encoding, detected_encoding(str), **encoding_options)
10571058
end
10581059

10591060
def run_command(git_cmd, &block)

tests/units/test_logger.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_logger
1919
@git.branches.size
2020

2121
logc = File.read(log.path)
22-
assert(/INFO -- : git '--git-dir=[^']+' '--work-tree=[^']+' branch '-a'/.match(logc))
22+
assert(/INFO -- : git '--git-dir=[^']+' '--work-tree=[^']+' '-c' 'color.ui=false' branch '-a'/.match(logc))
2323
assert(/DEBUG -- : diff_over_patches/.match(logc))
2424

2525
log = Tempfile.new('logfile')
@@ -31,7 +31,7 @@ def test_logger
3131
@git.branches.size
3232

3333
logc = File.read(log.path)
34-
assert(/INFO -- : git '--git-dir=[^']+' '--work-tree=[^']+' branch '-a'/.match(logc))
34+
assert(/INFO -- : git '--git-dir=[^']+' '--work-tree=[^']+' '-c' 'color.ui=false' branch '-a'/.match(logc))
3535
assert(!/DEBUG -- : diff_over_patches/.match(logc))
3636
end
3737

0 commit comments

Comments
 (0)