Skip to content

Commit

Permalink
Last test for url2name
Browse files Browse the repository at this point in the history
  • Loading branch information
abitrolly committed Nov 23, 2023
1 parent ffde3c7 commit 3873711
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Library/Homebrew/dev-cmd/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions Library/Homebrew/formula_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/test/dev-cmd/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3873711

Please sign in to comment.