extend/pathname: import rmtree again.

The separate file is no longer required now that
https://github.com/sorbet/sorbet/pull/7895 was merged.
This commit is contained in:
Mike McQuaid 2024-05-18 08:16:34 +01:00 committed by Markus Reiter
parent b0af3c6983
commit a92e6fc1c8
No known key found for this signature in database
GPG Key ID: 245293B51702655B
4 changed files with 15 additions and 23 deletions

View File

@ -284,7 +284,6 @@ Sorbet/TrueSigil:
- "/**/{Formula,Casks}/**/*.rb" - "/**/{Formula,Casks}/**/*.rb"
- "**/{Formula,Casks}/**/*.rb" - "**/{Formula,Casks}/**/*.rb"
- "Homebrew/test/**/*.rb" - "Homebrew/test/**/*.rb"
- "Homebrew/extend/pathname/rmtree.rb"
# Require &&/|| instead of and/or # Require &&/|| instead of and/or
Style/AndOr: Style/AndOr:

View File

@ -33,7 +33,6 @@ Style/Documentation:
- extend/ENV/super.rb - extend/ENV/super.rb
- extend/kernel.rb - extend/kernel.rb
- extend/pathname.rb - extend/pathname.rb
- extend/pathname/rmtree.rb
- formula.rb - formula.rb
- formula_assertions.rb - formula_assertions.rb
- formula_free_port.rb - formula_free_port.rb

View File

@ -498,6 +498,21 @@ class Pathname
.encode(Encoding::UTF_8, invalid: :replace) .encode(Encoding::UTF_8, invalid: :replace)
.split("\n") .split("\n")
end end
# Like regular `rmtree`, except it never ignores errors.
#
# This was the default behaviour in Ruby 3.1 and earlier.
#
# @api public
def rmtree(noop: nil, verbose: nil, secure: nil)
# Ideally we'd odeprecate this but probably can't given gems so let's
# create a RuboCop autocorrect instead soon.
# This is why monkeypatching is non-ideal (but right solution to get
# Ruby 3.3 over the line).
# odeprecated "rmtree", "FileUtils#rm_r"
FileUtils.rm_r(@path, noop:, verbose:, secure:)
nil
end
end end
require "extend/os/pathname" require "extend/os/pathname"
@ -584,5 +599,3 @@ module ObserverPathnameExtension
puts "uninfo #{self}" if ObserverPathnameExtension.verbose? puts "uninfo #{self}" if ObserverPathnameExtension.verbose?
end end
end end
require "extend/pathname/rmtree"

View File

@ -1,19 +0,0 @@
# typed: false
# frozen_string_literal: true
class Pathname
# Like regular `rmtree`, except it never ignores errors.
#
# This was the default behaviour in Ruby 3.1 and earlier.
#
# @api public
def rmtree(noop: nil, verbose: nil, secure: nil)
# Ideally we'd odeprecate this but probably can't given gems so let's
# create a RuboCop autocorrect instead soon.
# This is why monkeypatching is non-ideal (but right solution to get
# Ruby 3.3 over the line).
# odeprecated "rmtree", "FileUtils#rm_r"
FileUtils.rm_r(@path, noop:, verbose:, secure:)
nil
end
end