From 76059242320ed6d1dee55a625b59a99b0e26fc09 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Mon, 30 Mar 2020 20:44:01 +0100 Subject: [PATCH] When a HEAD build fails, output an instruction to raise PRs not issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. ``` --- Library/Homebrew/brew.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 939e73bba3..a55184628c 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -35,6 +35,13 @@ rescue MissingEnvironmentVariables => e exec ENV["HOMEBREW_BREW_FILE"], *ARGV 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 trap("INT", std_trap) # restore default CTRL-C handler @@ -141,12 +148,18 @@ rescue Interrupt rescue BuildError => e Utils::Analytics.report_build_error(e) e.dump + + head_unsupported_error if Homebrew.args.HEAD? + exit 1 rescue RuntimeError, SystemCallError => e raise if e.message.empty? onoe e $stderr.puts e.backtrace if ARGV.debug? + + head_unsupported_error if Homebrew.args.HEAD? + exit 1 rescue MethodDeprecatedError => e onoe e