When a HEAD build fails, output an instruction to raise PRs not issues

- This has to be in multiple places, hence a new method. A patch failing
  to apply, which is a common occurrence with HEAD builds because the
  patch is already upstream, raises a different exception to another,
  "normal" build failure.

Tested with:

```
╭─issyl0@rigel /home/linuxbrew/.linuxbrew/Homebrew ‹head-builds-arent-officially-supported*›
╰─ $ brew install --HEAD mtr
==> Cloning https://github.com/traviscross/mtr.git
Updating /home/issyl0/.cache/Homebrew/mtr--git
==> Checking out branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
HEAD is now at 155f76a Merge pull request #340 from Sea-n/master
==> Downloading https://github.com/traviscross/mtr/pull/315.patch?full_index=1
Already downloaded: /home/issyl0/.cache/Homebrew/downloads/82d9d939303d8fceb7a3ae071ecd49a5f075e0fb451b308653b555ffbae74336--315.patch
==> Patching
==> Applying 315.patch
patching file packet/probe.c
Hunk #1 FAILED at 323.
Hunk #2 FAILED at 364.
2 out of 2 hunks FAILED -- saving rejects to file packet/probe.c.rej
Error: Failure while executing; `patch -g 0 -f -p1 -i /tmp/mtr--patch-20200330-10734-avjmyy/315.patch` exited with 1.
HEAD builds are unsupported by maintainers - please file pull requests instead of issues.
```

and

```
╭─issyl0@rigel /home/linuxbrew/.linuxbrew/Homebrew ‹head-builds-arent-officially-supported*›
╰─ $ brew install --HEAD zookeeper
==> Cloning https://gitbox.apache.org/repos/asf/zookeeper.git
Updating /home/issyl0/.cache/Homebrew/zookeeper--git
==> Checking out branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
HEAD is now at 1ff1b779 ZOOKEEPER-3755: Use maven to create fatjar
==> ant compile_jute
Last 15 lines from /home/issyl0/.cache/Homebrew/Logs/zookeeper/01.ant:
2020-03-30 21:45:10 +0100

ant
compile_jute

Picked up _JAVA_OPTIONS: -Duser.home=/home/issyl0/.cache/Homebrew/java_cache
Buildfile: build.xml does not exist!
Build failed

READ THIS: https://docs.brew.sh/Troubleshooting

HEAD builds are unsupported by maintainers - please file pull requests instead of issues.
```
This commit is contained in:
Issy Long 2020-03-30 20:44:01 +01:00
parent ed0985783a
commit 7605924232
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -35,6 +35,13 @@ rescue MissingEnvironmentVariables => e
exec ENV["HOMEBREW_BREW_FILE"], *ARGV exec ENV["HOMEBREW_BREW_FILE"], *ARGV
end end
def head_unsupported_error
$stderr.puts <<~EOS
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC.
EOS
end
begin begin
trap("INT", std_trap) # restore default CTRL-C handler trap("INT", std_trap) # restore default CTRL-C handler
@ -141,12 +148,18 @@ rescue Interrupt
rescue BuildError => e rescue BuildError => e
Utils::Analytics.report_build_error(e) Utils::Analytics.report_build_error(e)
e.dump e.dump
head_unsupported_error if Homebrew.args.HEAD?
exit 1 exit 1
rescue RuntimeError, SystemCallError => e rescue RuntimeError, SystemCallError => e
raise if e.message.empty? raise if e.message.empty?
onoe e onoe e
$stderr.puts e.backtrace if ARGV.debug? $stderr.puts e.backtrace if ARGV.debug?
head_unsupported_error if Homebrew.args.HEAD?
exit 1 exit 1
rescue MethodDeprecatedError => e rescue MethodDeprecatedError => e
onoe e onoe e