public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-ruby/pathutil/files/
@ 2023-04-04  5:54 Hans de Graaff
  0 siblings, 0 replies; only message in thread
From: Hans de Graaff @ 2023-04-04  5:54 UTC (permalink / raw
  To: gentoo-commits

commit:     7717f684986360d239ee03d43409b03b33af21b6
Author:     Hans de Graaff <graaff <AT> gentoo <DOT> org>
AuthorDate: Sun Apr  2 07:02:26 2023 +0000
Commit:     Hans de Graaff <graaff <AT> gentoo <DOT> org>
CommitDate: Tue Apr  4 05:54:50 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7717f684

dev-ruby/pathutil: add missing patch file

Closes: https://bugs.gentoo.org/903662
Signed-off-by: Hans de Graaff <graaff <AT> gentoo.org>

 .../pathutil/files/pathutil-0.16.2-ruby30.patch    | 195 +++++++++++++++++++++
 1 file changed, 195 insertions(+)

diff --git a/dev-ruby/pathutil/files/pathutil-0.16.2-ruby30.patch b/dev-ruby/pathutil/files/pathutil-0.16.2-ruby30.patch
new file mode 100644
index 000000000000..374cd4005930
--- /dev/null
+++ b/dev-ruby/pathutil/files/pathutil-0.16.2-ruby30.patch
@@ -0,0 +1,195 @@
+From 3451a10c362fc867b20c7e471a551b31c40a0246 Mon Sep 17 00:00:00 2001
+From: Tom Dunlap <tom@motevets.com>
+Date: Tue, 9 Jun 2020 12:59:32 -0400
+Subject: [PATCH] Fix ruby keyword parameter deprecation warnings
+
+In ruby 2.7, using the last argument as keyword parameters became
+deprecated in preparation for ruby 3.0. When running the tests, we saw
+numerous deprecation warnings. This commit fixes up those deprecation
+warnings by explicitly passing the last argument(s) as keyword
+argument(s).
+
+See: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
+
+Fixes #4
+
+Side note: this commit did not fix the `#binread` method because it was
+untested, and when attempting to add tests, we got the following failing
+test:
+
+```
+1) Pathutil#binread when set to normalize should use encode to convert CRLF to LF
+   Failure/Error:
+     File.binread(self, *args, kwd).encode({
+       :universal_newline => true
+     })
+
+   TypeError:
+     no implicit conversion of Hash into Integer
+   # ./lib/pathutil.rb:509:in `binread'
+   # ./lib/pathutil.rb:509:in `binread'
+   # ./spec/tests/lib/pathutil_spec.rb:943:in `block (4 levels) in <top (required)>'
+```
+
+...which appears to be occuring because of an interface mismatch as
+`IO#binread` does not take keyword arguments.
+
+https://ruby-doc.org/core-2.7.1/IO.html#method-c-binread
+---
+ lib/pathutil.rb                         | 36 ++++++++-----------------
+ spec/tests/lib/pathutil/helpers_spec.rb |  4 +--
+ spec/tests/lib/pathutil_spec.rb         | 13 +++------
+ 3 files changed, 16 insertions(+), 37 deletions(-)
+
+diff --git a/lib/pathutil.rb b/lib/pathutil.rb
+index 1a15873..80913f2 100644
+--- a/lib/pathutil.rb
++++ b/lib/pathutil.rb
+@@ -456,14 +456,10 @@ def safe_copy(to, root: nil, ignore: [])
+     to   = self.class.new(to)
+ 
+     if directory?
+-      safe_copy_directory(to, {
+-        :root => root, :ignore => ignore
+-      })
++      safe_copy_directory(to, root: root, ignore: ignore)
+ 
+     else
+-      safe_copy_file(to, {
+-        :root => root
+-      })
++      safe_copy_file(to, root: root)
+     end
+   end
+ 
+@@ -494,14 +490,10 @@ def read(*args, **kwd)
+     kwd[:encoding] ||= encoding
+ 
+     if normalize[:read]
+-      File.read(self, *args, kwd).encode({
+-        :universal_newline => true
+-      })
++      File.read(self, *args, **kwd).encode(universal_newline: true)
+ 
+     else
+-      File.read(
+-        self, *args, kwd
+-      )
++      File.read(self, *args, **kwd)
+     end
+   end
+ 
+@@ -534,13 +526,13 @@ def readlines(*args, **kwd)
+     kwd[:encoding] ||= encoding
+ 
+     if normalize[:read]
+-      File.readlines(self, *args, kwd).encode({
++      File.readlines(self, *args, **kwd).encode({
+         :universal_newline => true
+       })
+ 
+     else
+       File.readlines(
+-        self, *args, kwd
++        self, *args, **kwd
+       )
+     end
+   end
+@@ -556,11 +548,11 @@ def write(data, *args, **kwd)
+     if normalize[:write]
+       File.write(self, data.encode(
+         :crlf_newline => true
+-      ), *args, kwd)
++      ), *args, **kwd)
+ 
+     else
+       File.write(
+-        self, data, *args, kwd
++        self, data, *args, **kwd
+       )
+     end
+   end
+@@ -670,9 +662,7 @@ def expanded_paths(path)
+   private
+   def safe_copy_file(to, root: nil)
+     raise Errno::EPERM, "#{self} not in #{root}" unless in_path?(root)
+-    FileUtils.cp(self, to, {
+-      :preserve => true
+-    })
++    FileUtils.cp(self, to, preserve: true)
+   end
+ 
+   # --
+@@ -697,15 +687,11 @@ def safe_copy_directory(to, root: nil, ignore: [])
+             }"
+ 
+           elsif file.file?
+-            FileUtils.cp(file, to, {
+-              :preserve => true
+-            })
++            FileUtils.cp(file, to, preserve: true)
+ 
+           else
+             path = file.realpath
+-            path.safe_copy(to.join(file.basename), {
+-              :root => root, :ignore => ignore
+-            })
++            path.safe_copy(to.join(file.basename), root: root, ignore: ignore)
+           end
+         end
+       end
+diff --git a/spec/tests/lib/pathutil/helpers_spec.rb b/spec/tests/lib/pathutil/helpers_spec.rb
+index 4d64d0a..0dfbc00 100644
+--- a/spec/tests/lib/pathutil/helpers_spec.rb
++++ b/spec/tests/lib/pathutil/helpers_spec.rb
+@@ -76,9 +76,7 @@
+           #
+ 
+           after do
+-            described_class.load_yaml("hello: world", {
+-              :aliases => true
+-            })
++            described_class.load_yaml("hello: world", aliases: true)
+           end
+         end
+ 
+diff --git a/spec/tests/lib/pathutil_spec.rb b/spec/tests/lib/pathutil_spec.rb
+index 784a16b..0ee7a12 100644
+--- a/spec/tests/lib/pathutil_spec.rb
++++ b/spec/tests/lib/pathutil_spec.rb
+@@ -944,9 +944,7 @@
+ 
+     context "with an encoding argument" do
+       before do
+-        file.write("hello", {
+-          :encoding => "ASCII"
+-        })
++        file.write("hello", encoding: "ASCII")
+       end
+ 
+       #
+@@ -1050,11 +1048,10 @@
+           name1.join(name2.basename, name1.basename).touch
+           name1.join(name1.basename).touch
+ 
+-          name1.safe_copy(name2, {
+-            :root => tmpdir1, :ignore => [
++          name1.safe_copy(name2, root: tmpdir1, ignore: [
+               name1.join(name2.basename, name1.basename)
+             ]
+-          })
++          )
+         end
+ 
+         #
+@@ -1077,9 +1074,7 @@
+           name1.join(name2.basename, name1.basename).touch
+           name1.join(name1.basename).touch
+ 
+-          name1.safe_copy(name2, {
+-            :root => tmpdir1
+-          })
++          name1.safe_copy(name2, root: tmpdir1)
+         end
+ 
+         #


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-04  5:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-04  5:54 [gentoo-commits] repo/gentoo:master commit in: dev-ruby/pathutil/files/ Hans de Graaff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox