diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index ae869d5e08..f169e10179 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -148,12 +148,15 @@ class Build # https://github.com/Homebrew/homebrew-core/pull/87470 TZ: "UTC0", ) do - formula.patch - if args.git? + formula.selective_patch(is_data: false) system "git", "init" system "git", "add", "-A" + formula.selective_patch(is_data: true) + else + formula.patch end + if args.interactive? ohai "Entering interactive mode..." puts <<~EOS diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 1bfd73a0e2..9a024f9eb7 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1608,6 +1608,20 @@ class Formula patchlist.each(&:apply) end + sig { params(is_data: T::Boolean).void } + def selective_patch(is_data: false) + patches = patchlist.select { |p| p.is_a?(DATAPatch) == is_data } + return if patches.empty? + + patchtype = if is_data + "DATA" + else + "non-DATA" + end + ohai "Applying #{patchtype} patches" + patches.each(&:apply) + end + # Yields |self,staging| with current working directory set to the uncompressed tarball # where staging is a {Mktemp} staging context. sig(:final) {