Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ActiveSupport String#indent core extension #16451

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/object/deep_dup.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/object/duplicable.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/string/exclude.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/string/indent.rb

# Ignore partially included gems where we don't need all files
**/vendor/gems/mechanize-*/.*
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
require "active_support/core_ext/hash/deep_merge"
require "active_support/core_ext/hash/keys"
require "active_support/core_ext/string/exclude"
require "active_support/core_ext/string/indent"

HOMEBREW_API_DEFAULT_DOMAIN = ENV.fetch("HOMEBREW_API_DEFAULT_DOMAIN").freeze
HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV.fetch("HOMEBREW_BOTTLE_DEFAULT_DOMAIN").freeze
Expand Down
22 changes: 11 additions & 11 deletions Library/Homebrew/test/dev-cmd/bottle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,11 @@ def install
bottle.sha256(catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e")

expect(homebrew.bottle_output(bottle, nil)).to eq(
<<~RUBY.indent(2),
bottle do
root_url "https://example.com"
sha256 catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e"
end
<<-RUBY,
bottle do
root_url "https://example.com"
sha256 catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e"
end
RUBY
)
end
Expand All @@ -526,12 +526,12 @@ def install
bottle.sha256(catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e")

expect(homebrew.bottle_output(bottle, "ExampleStrategy")).to eq(
<<~RUBY.indent(2),
bottle do
root_url "https://example.com",
using: ExampleStrategy
sha256 catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e"
end
<<-RUBY,
bottle do
root_url "https://example.com",
using: ExampleStrategy
sha256 catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e"
end
RUBY
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def install
Formulary.core_path(name).tap do |formula_path|
formula_path.write <<~RUBY
class #{Formulary.class_s(name)} < Formula
#{content.indent(2)}
#{content.gsub(/^(?!$)/, " ")}
end
RUBY
end
Expand Down
18 changes: 9 additions & 9 deletions Library/Homebrew/test/utils/ast/ast_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
describe Utils::AST do
describe ".stanza_text" do
let(:compound_license) do
<<~RUBY.chomp
license all_of: [
:public_domain,
"MIT",
"GPL-3.0-or-later" => { with: "Autoconf-exception-3.0" },
]
<<-RUBY
license all_of: [
:public_domain,
"MIT",
"GPL-3.0-or-later" => { with: "Autoconf-exception-3.0" },
]
RUBY
end

Expand All @@ -36,14 +36,14 @@
it "adds indent to stanza text if specified" do
expect(described_class.stanza_text(:revision, "revision 1", indent: 2)).to eq(" revision 1")
expect(described_class.stanza_text(:license, 'license "MIT"', indent: 2)).to eq(' license "MIT"')
expect(described_class.stanza_text(:license, compound_license, indent: 2)).to eq(compound_license.indent(2))
expect(described_class.stanza_text(:license, compound_license, indent: 2)).to eq(compound_license)
end

it "does not add indent if already indented" do
expect(described_class.stanza_text(:revision, " revision 1", indent: 2)).to eq(" revision 1")
expect(
described_class.stanza_text(:license, compound_license.indent(2), indent: 2),
).to eq(compound_license.indent(2))
described_class.stanza_text(:license, compound_license, indent: 2),
).to eq(compound_license)
end
end
end
8 changes: 4 additions & 4 deletions Library/Homebrew/test/utils/ast/formula_ast_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ class Foo < Formula

describe "#add_bottle_block" do
let(:bottle_output) do
<<~RUBY.chomp.indent(2)
bottle do
sha256 "f7b1fc772c79c20fddf621ccc791090bc1085fcef4da6cca03399424c66e06ca" => :sierra
end
<<-RUBY
bottle do
sha256 "f7b1fc772c79c20fddf621ccc791090bc1085fcef4da6cca03399424c66e06ca" => :sierra
end
RUBY
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/utils/ast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def stanza_text(name, value, indent: nil)
value if (node.is_a?(SendNode) || node.is_a?(BlockNode)) && node.method_name == name
end
text ||= "#{name} #{value.inspect}"
text = text.indent(indent) if indent && !text.match?(/\A\n* +/)
text = text.gsub(/^(?!$)/, " " * indent) if indent && !text.match?(/\A\n* +/)
text
end

Expand Down

This file was deleted.