aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/create.rb
diff options
context:
space:
mode:
authorBaptiste Fontaine2015-10-26 16:01:16 +0100
committerBaptiste Fontaine2015-10-28 14:04:53 +0100
commit75c196c1fc7347661bc888ae1ead8be49e5494eb (patch)
tree0825b7fc5e215f4709a58c9cc6af20a252c64ecb /Library/Homebrew/cmd/create.rb
parent74e407dc548f397159ee0eab6d0921bd0666b3b3 (diff)
downloadbrew-75c196c1fc7347661bc888ae1ead8be49e5494eb.tar.bz2
create: accept HEAD urls
Fixes Homebrew/homebrew#45310. Closes Homebrew/homebrew#45336. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Diffstat (limited to 'Library/Homebrew/cmd/create.rb')
-rw-r--r--Library/Homebrew/cmd/create.rb24
1 files changed, 19 insertions, 5 deletions
diff --git a/Library/Homebrew/cmd/create.rb b/Library/Homebrew/cmd/create.rb
index b64f3c10b..e98686c5c 100644
--- a/Library/Homebrew/cmd/create.rb
+++ b/Library/Homebrew/cmd/create.rb
@@ -78,10 +78,16 @@ class FormulaCreator
@url = url
path = Pathname.new(url)
if @name.nil?
- %r{github.com/\S+/(\S+)/archive/}.match url
- @name ||= $1
- /(.*?)[-_.]?#{path.version}/.match path.basename
- @name ||= $1
+ case url
+ 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
+ @name = $1
+ end
@path = Formulary.path @name unless @name.nil?
else
@path = Formulary.path name
@@ -94,7 +100,11 @@ class FormulaCreator
end
def fetch?
- !ARGV.include?("--no-fetch")
+ !head? && !ARGV.include?("--no-fetch")
+ end
+
+ def head?
+ @head || ARGV.build_head?
end
def generate!
@@ -124,11 +134,15 @@ class FormulaCreator
class #{Formulary.class_s(name)} < Formula
desc ""
homepage ""
+ <% if head? %>
+ head "#{url}"
+ <% else %>
url "#{url}"
<% unless version.nil? or version.detected_from_url? %>
version "#{version}"
<% end %>
sha256 "#{sha256}"
+ <% end %>
<% if mode == :cmake %>
depends_on "cmake" => :build