formula_creator: Pass url to constructor
This commit is contained in:
parent
a7756bd303
commit
dd939340fd
@ -166,6 +166,7 @@ module Homebrew
|
|||||||
args.set_name,
|
args.set_name,
|
||||||
args.set_version,
|
args.set_version,
|
||||||
tap: args.tap,
|
tap: args.tap,
|
||||||
|
url: args.named.first,
|
||||||
mode: mode,
|
mode: mode,
|
||||||
license: args.set_license,
|
license: args.set_license,
|
||||||
fetch: !args.no_fetch?,
|
fetch: !args.no_fetch?,
|
||||||
@ -177,7 +178,7 @@ module Homebrew
|
|||||||
fc.name = __gets || stem
|
fc.name = __gets || stem
|
||||||
end
|
end
|
||||||
|
|
||||||
fc.url = args.named.first
|
fc.parse_url
|
||||||
|
|
||||||
fc.verify
|
fc.verify
|
||||||
|
|
||||||
|
|||||||
@ -12,13 +12,14 @@ module Homebrew
|
|||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(name: T.nilable(String), version: T.nilable(String), tap: T.nilable(String), mode: T.nilable(Symbol),
|
params(name: T.nilable(String), version: T.nilable(String), tap: T.nilable(String), url: String,
|
||||||
license: T.nilable(String), fetch: T::Boolean, head: T::Boolean).void
|
mode: T.nilable(Symbol), license: T.nilable(String), fetch: T::Boolean, head: T::Boolean).void
|
||||||
}
|
}
|
||||||
def initialize(name, version, tap:, mode:, license:, fetch: true, head: false)
|
def initialize(name, version, tap:, url:, mode:, license:, fetch: true, head: false)
|
||||||
@name = name
|
@name = name
|
||||||
@version = Version.new(version) if version
|
@version = Version.new(version) if version
|
||||||
@tap = Tap.fetch(tap || "homebrew/core")
|
@tap = Tap.fetch(tap || "homebrew/core")
|
||||||
|
@url = url
|
||||||
@mode = mode
|
@mode = mode
|
||||||
@license = license
|
@license = license
|
||||||
@fetch = fetch
|
@fetch = fetch
|
||||||
@ -30,11 +31,10 @@ module Homebrew
|
|||||||
raise TapUnavailableError, @tap.name unless @tap.installed?
|
raise TapUnavailableError, @tap.name unless @tap.installed?
|
||||||
end
|
end
|
||||||
|
|
||||||
def url=(url)
|
def parse_url
|
||||||
@url = url
|
path = Pathname.new(@url)
|
||||||
path = Pathname.new(url)
|
|
||||||
if @name.nil?
|
if @name.nil?
|
||||||
case url
|
case @url
|
||||||
when %r{github\.com/(\S+)/(\S+)\.git}
|
when %r{github\.com/(\S+)/(\S+)\.git}
|
||||||
@user = Regexp.last_match(1)
|
@user = Regexp.last_match(1)
|
||||||
@name = Regexp.last_match(2)
|
@name = Regexp.last_match(2)
|
||||||
@ -48,7 +48,7 @@ module Homebrew
|
|||||||
@name = path.basename.to_s[/(.*?)[-_.]?#{Regexp.escape(path.version.to_s)}/, 1]
|
@name = path.basename.to_s[/(.*?)[-_.]?#{Regexp.escape(path.version.to_s)}/, 1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@version = Version.detect(url) if @version.nil?
|
@version = Version.detect(@url) if @version.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_formula!
|
def write_formula!
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user