diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb index 39ba0ac62275d7..3323ca3d18479c 100644 --- a/Library/Homebrew/dev-cmd/create.rb +++ b/Library/Homebrew/dev-cmd/create.rb @@ -81,7 +81,8 @@ def url2name(url) elsif url =~ %r{github\.com/\S+/(\S+)/(archive|releases)/} Regexp.last_match(1) else - stem + pathver = Version.parse(stem).to_s + stem.sub(/[-_.]?#{Regexp.escape(pathver)}$/, "") end odebug "url2name: #{name}" name diff --git a/Library/Homebrew/formula_creator.rb b/Library/Homebrew/formula_creator.rb index 6cc5a8569096bd..fb4bd7f49182d5 100644 --- a/Library/Homebrew/formula_creator.rb +++ b/Library/Homebrew/formula_creator.rb @@ -18,8 +18,7 @@ def initialize(args) def url=(url) @url = url - path = Pathname.new(url) - if @name.nil? + if @user.nil? case url when %r{github\.com/(\S+)/(\S+)\.git} @user = Regexp.last_match(1) @@ -28,8 +27,6 @@ def url=(url) when %r{github\.com/(\S+)/(\S+)/(archive|releases)/} @user = Regexp.last_match(1) @github = true - else - @name = path.basename.to_s[/(.*?)[-_.]?#{Regexp.escape(path.version.to_s)}/, 1] end end @version = if @version diff --git a/Library/Homebrew/test/dev-cmd/create_spec.rb b/Library/Homebrew/test/dev-cmd/create_spec.rb index a3d254d8f77871..662f971e513c9a 100644 --- a/Library/Homebrew/test/dev-cmd/create_spec.rb +++ b/Library/Homebrew/test/dev-cmd/create_spec.rb @@ -30,5 +30,7 @@ expect(t).to eq("lapce") t = Homebrew.url2name("https://github.com/stella-emu/stella/releases/download/6.7/stella-6.7-src.tar.xz") expect(t).to eq("stella") + t = Homebrew.url2name("http://digit-labs.org/files/tools/synscan/releases/synscan-5.02.tar.gz") + expect(t).to eq("synscan") end end