From 1ab843ba47374577216c28bb4a1c2fa67666da34 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 14 Feb 2020 22:38:05 +0000 Subject: [PATCH] bump-formula-pr: Only delete Linux bottle line if it exists - We have some Linux-only formulae that don't have bottles. - Previously, bumping a Linux-only formula that didn't have a bottle line - eg, `adoptopenjdk` which is `bottle :unneeded` - would fail: ``` Error: inreplace failed /app/linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/adoptopenjdk.rb: expected replacement of /^ sha256 ".+" => :x86_64_linux\n/m with "\2" ``` --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 4102b51539..545819f569 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -256,10 +256,11 @@ module Homebrew ] end - # When bumping a linux-only formula, - # one needs to also delete the sha256 linux bottle line. - # That's because of running test-bot with --keep-old option in linuxbrew-core. - if formula.path.read.include?("depends_on :linux") + # When bumping a linux-only formula, one needs to also delete the + # sha256 linux bottle line if it exists. That's because of running + # test-bot with --keep-old option in linuxbrew-core. + formula_contents = formula.path.read + if formula_contents.include?("depends_on :linux") && formula_contents.include?("=> :x86_64_linux") replacement_pairs << [ /^ sha256 ".+" => :x86_64_linux\n/m, "\\2",