create: accept HEAD urls

Fixes Homebrew/homebrew#45310.

Closes Homebrew/homebrew#45336.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
Baptiste Fontaine 2015-10-26 16:01:16 +01:00
parent 74e407dc54
commit 75c196c1fc

View File

@ -78,10 +78,16 @@ class FormulaCreator
@url = url @url = url
path = Pathname.new(url) path = Pathname.new(url)
if @name.nil? if @name.nil?
%r{github.com/\S+/(\S+)/archive/}.match url case url
@name ||= $1 when %r{github\.com/\S+/(\S+)\.git}
@name = $1
@head = true
when %r{github\.com/\S+/(\S+)/archive/}
@name = $1
else
/(.*?)[-_.]?#{path.version}/.match path.basename /(.*?)[-_.]?#{path.version}/.match path.basename
@name ||= $1 @name = $1
end
@path = Formulary.path @name unless @name.nil? @path = Formulary.path @name unless @name.nil?
else else
@path = Formulary.path name @path = Formulary.path name
@ -94,7 +100,11 @@ class FormulaCreator
end end
def fetch? def fetch?
!ARGV.include?("--no-fetch") !head? && !ARGV.include?("--no-fetch")
end
def head?
@head || ARGV.build_head?
end end
def generate! def generate!
@ -124,11 +134,15 @@ class FormulaCreator
class #{Formulary.class_s(name)} < Formula class #{Formulary.class_s(name)} < Formula
desc "" desc ""
homepage "" homepage ""
<% if head? %>
head "#{url}"
<% else %>
url "#{url}" url "#{url}"
<% unless version.nil? or version.detected_from_url? %> <% unless version.nil? or version.detected_from_url? %>
version "#{version}" version "#{version}"
<% end %> <% end %>
sha256 "#{sha256}" sha256 "#{sha256}"
<% end %>
<% if mode == :cmake %> <% if mode == :cmake %>
depends_on "cmake" => :build depends_on "cmake" => :build