Merge pull request #16244 from abitrolly/depath-create
formula_creator: Remove `path` attr to reduce code complexity
This commit is contained in:
commit
942e77d3a8
@ -200,7 +200,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fc.generate!
|
path = fc.write_formula!
|
||||||
|
|
||||||
formula = Homebrew.with_no_api_env do
|
formula = Homebrew.with_no_api_env do
|
||||||
Formula[fc.name]
|
Formula[fc.name]
|
||||||
@ -208,7 +208,7 @@ module Homebrew
|
|||||||
PyPI.update_python_resources! formula, ignore_non_pypi_packages: true if args.python?
|
PyPI.update_python_resources! formula, ignore_non_pypi_packages: true if args.python?
|
||||||
|
|
||||||
puts "Please run `brew audit --new #{fc.name}` before submitting, thanks."
|
puts "Please run `brew audit --new #{fc.name}` before submitting, thanks."
|
||||||
fc.path
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
def __gets
|
def __gets
|
||||||
|
@ -10,7 +10,7 @@ module Homebrew
|
|||||||
# @api private
|
# @api private
|
||||||
class FormulaCreator
|
class FormulaCreator
|
||||||
attr_reader :args, :url, :sha256, :desc, :homepage
|
attr_reader :args, :url, :sha256, :desc, :homepage
|
||||||
attr_accessor :name, :version, :tap, :path, :mode, :license
|
attr_accessor :name, :version, :tap, :mode, :license
|
||||||
|
|
||||||
def initialize(args)
|
def initialize(args)
|
||||||
@args = args
|
@args = args
|
||||||
@ -34,7 +34,6 @@ 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
|
||||||
update_path
|
|
||||||
@version = if @version
|
@version = if @version
|
||||||
Version.new(@version)
|
Version.new(@version)
|
||||||
else
|
else
|
||||||
@ -42,12 +41,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_path
|
|
||||||
return if @name.nil? || @tap.nil?
|
|
||||||
|
|
||||||
@path = @tap.new_formula_path(@name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def fetch?
|
def fetch?
|
||||||
!args.no_fetch?
|
!args.no_fetch?
|
||||||
end
|
end
|
||||||
@ -56,7 +49,11 @@ module Homebrew
|
|||||||
@head || args.HEAD?
|
@head || args.HEAD?
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate!
|
def write_formula!
|
||||||
|
raise ArgumentError, "name is blank!" if @name.blank?
|
||||||
|
raise ArgumentError, "tap is blank!" if @tap.blank?
|
||||||
|
|
||||||
|
path = @tap.new_formula_path(@name)
|
||||||
raise "#{path} already exists" if path.exist?
|
raise "#{path} already exists" if path.exist?
|
||||||
|
|
||||||
if version.nil? || version.null?
|
if version.nil? || version.null?
|
||||||
@ -86,6 +83,7 @@ module Homebrew
|
|||||||
|
|
||||||
path.dirname.mkpath
|
path.dirname.mkpath
|
||||||
path.write ERB.new(template, trim_mode: ">").result(binding)
|
path.write ERB.new(template, trim_mode: ">").result(binding)
|
||||||
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(String) }
|
sig { returns(String) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user