FormulaVersions: load from contents to reduce io
This commit is contained in:
parent
61c8f69c25
commit
11f0979dfb
@ -7,12 +7,13 @@ class FormulaVersions
|
|||||||
ErrorDuringExecution, LoadError
|
ErrorDuringExecution, LoadError
|
||||||
]
|
]
|
||||||
|
|
||||||
attr_reader :name, :repository, :entry_name
|
attr_reader :name, :path, :repository, :entry_name
|
||||||
|
|
||||||
def initialize(formula)
|
def initialize(formula)
|
||||||
@name = formula.name
|
@name = formula.name
|
||||||
|
@path = formula.path
|
||||||
@repository = formula.tap? ? HOMEBREW_LIBRARY.join("Taps", formula.tap) : HOMEBREW_REPOSITORY
|
@repository = formula.tap? ? HOMEBREW_LIBRARY.join("Taps", formula.tap) : HOMEBREW_REPOSITORY
|
||||||
@entry_name = formula.path.relative_path_from(repository).to_s
|
@entry_name = @path.relative_path_from(repository).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def rev_list(branch)
|
def rev_list(branch)
|
||||||
@ -28,19 +29,16 @@ class FormulaVersions
|
|||||||
end
|
end
|
||||||
|
|
||||||
def formula_at_revision(rev)
|
def formula_at_revision(rev)
|
||||||
FileUtils.mktemp(name) do
|
contents = file_contents_at_revision(rev)
|
||||||
path = Pathname.pwd.join("#{name}.rb")
|
|
||||||
path.write file_contents_at_revision(rev)
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
nostdout { yield Formulary.factory(path.to_s) }
|
nostdout { yield Formulary.from_contents(name, path, contents) }
|
||||||
rescue *IGNORED_EXCEPTIONS => e
|
rescue *IGNORED_EXCEPTIONS => e
|
||||||
# We rescue these so that we can skip bad versions and
|
# We rescue these so that we can skip bad versions and
|
||||||
# continue walking the history
|
# continue walking the history
|
||||||
ohai "#{e} in #{name} at revision #{rev}", e.backtrace if ARGV.debug?
|
ohai "#{e} in #{name} at revision #{rev}", e.backtrace if ARGV.debug?
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
# Suppress this error
|
# Suppress this error
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user