From 62753a5ec6b5aa7546b2abb269e6631866ee8573 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Thu, 27 Mar 2025 06:09:58 +0300 Subject: [PATCH 1/3] create: check that downloaded URL is actually archive My common mistake is to specify release URL, like brew crate https://github.com/hugelgupf/p9/releases/tag/v0.3.0 which gives unpacking errors later. It should be archive instead brew create https://github.com/hugelgupf/p9/archive/refs/tags/v0.3.0.tar.gz Ideally we can try to autodetect the archive from release page, but erroring out if downloaded file is HTML page should be handy for early spotting other URL mistakes too. --- Library/Homebrew/formula_creator.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formula_creator.rb b/Library/Homebrew/formula_creator.rb index 609d23e8d7..74f1b55176 100644 --- a/Library/Homebrew/formula_creator.rb +++ b/Library/Homebrew/formula_creator.rb @@ -82,7 +82,10 @@ module Homebrew r = Resource.new r.url(@url) r.owner = self - @sha256 = r.fetch.sha256 if r.download_strategy == CurlDownloadStrategy + filepath = r.fetch + raise "Downloaded URL is not archive" if File.read(filepath, 100).strip.start_with?("") + + @sha256 = filepath.sha256 end if @github From 9f1093266dadad30fb32d3dfed0107e8c209c8c4 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Fri, 28 Mar 2025 06:59:02 +0300 Subject: [PATCH 2/3] Update Library/Homebrew/formula_creator.rb Co-authored-by: Mike McQuaid --- Library/Homebrew/formula_creator.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formula_creator.rb b/Library/Homebrew/formula_creator.rb index 74f1b55176..00d94f57e0 100644 --- a/Library/Homebrew/formula_creator.rb +++ b/Library/Homebrew/formula_creator.rb @@ -83,7 +83,8 @@ module Homebrew r.url(@url) r.owner = self filepath = r.fetch - raise "Downloaded URL is not archive" if File.read(filepath, 100).strip.start_with?("") + html_doctype_prefix = " Date: Fri, 28 Mar 2025 07:05:53 +0300 Subject: [PATCH 3/3] create: fix brew style --- Library/Homebrew/formula_creator.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formula_creator.rb b/Library/Homebrew/formula_creator.rb index 00d94f57e0..f776b76a9c 100644 --- a/Library/Homebrew/formula_creator.rb +++ b/Library/Homebrew/formula_creator.rb @@ -84,7 +84,9 @@ module Homebrew r.owner = self filepath = r.fetch html_doctype_prefix = "