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"
```
This commit is contained in:
Issy Long 2020-02-14 22:38:05 +00:00
parent 23ab620cd4
commit 1ab843ba47
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -256,10 +256,11 @@ module Homebrew
] ]
end end
# When bumping a linux-only formula, # When bumping a linux-only formula, one needs to also delete the
# one needs to also delete the sha256 linux bottle line. # sha256 linux bottle line if it exists. That's because of running
# That's because of running test-bot with --keep-old option in linuxbrew-core. # test-bot with --keep-old option in linuxbrew-core.
if formula.path.read.include?("depends_on :linux") formula_contents = formula.path.read
if formula_contents.include?("depends_on :linux") && formula_contents.include?("=> :x86_64_linux")
replacement_pairs << [ replacement_pairs << [
/^ sha256 ".+" => :x86_64_linux\n/m, /^ sha256 ".+" => :x86_64_linux\n/m,
"\\2", "\\2",