Without this fix, a command like:
`brew bump-formula-pr --version=0.3.3 --tag=v0.3.3 --revision=... test-formula-git-revision`
will fail because:
```
Error: no implicit conversion of nil into String
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/bump-formula-pr.rb:281:in `escape'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/bump-formula-pr.rb:281:in `bump_formula_pr'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:111:in `<main>'
```
Additionally, reject all `nil` replacement pairs by calling `compact`
method.
- Sorbet gives preference to class methods over methods defined in
included modules, hence Sorbet was unavailable to resolve the
definition of the gsub! method.
- The gsub! method in StringInreplaceExtension conflicts with the definition in String.
- This PR refactors the call to the gsub! method so that a custom object
is exposed instead of a string.
- This fix was suggested by Sorbet when I ran `HOMEBREW_SORBET=1 bundle
exec srb tc` on the latest `master` while playing around with the
latest changes post-GSoC meeting.
- Then I noticed it was actually a bug, introduced in
adc36a05ffeadb54b94c87d86f62fba9dbb86795, found by us not being able to
publish bottles for [this build of the `n`
formula](https://github.com/Homebrew/homebrew-core/runs/910309641?check_suite_focus=true)
in https://github.com/Homebrew/homebrew-core/pull/58606:
```
[master 31d32307bd] n: update 6.7.0 bottle.
1 file changed, 3 insertions(+), 3 deletions(-)
curl: (22) The requested URL returned error: 404 Not Found
Error: uninitialized constant Bintray::EnvConfig
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/bintray.rb:28:in `open_api'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/bintray.rb:43:in `upload'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/bintray.rb:186:in `block (2 levels) in upload_bottle_json'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/bintray.rb:158:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/bintray.rb:158:in `block in upload_bottle_json'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/bintray.rb:153:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/bintray.rb:153:in `upload_bottle_json'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-upload.rb:54:in `pr_upload'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:111:in `<main>'
Error: Failure while executing; `/home/linuxbrew/.linuxbrew/bin/brew pr-upload --verbose --bintray-org=homebrew` exited with 1.
```
refines PatchELF #runpath, #rpath #soname #interpreter
to return nil.
let Brew hard exits on PatchELF::PatchError.
Co-authored-by: Shaun Jackman <sjackman@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>