formula: add new HEAD methods
* add `latest_head_version` to return latest HEAD version installed * add `latest_head_prefix` to return Pathname with latest HEAD version * add `head_version_outdated?` to check if HEAD version is up-to-date
This commit is contained in:
parent
00f37d6778
commit
1b88c2912b
@ -413,16 +413,36 @@ class Formula
|
|||||||
Pathname.new("#{HOMEBREW_LIBRARY}/LinkedKegs/#{name}")
|
Pathname.new("#{HOMEBREW_LIBRARY}/LinkedKegs/#{name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def latest_head_prefix
|
def latest_head_version
|
||||||
head_versions = installed_prefixes.map do |pn|
|
head_versions = installed_prefixes.map do |pn|
|
||||||
pn_pkgversion = PkgVersion.parse(pn.basename.to_s)
|
pn_pkgversion = PkgVersion.parse(pn.basename.to_s)
|
||||||
pn_pkgversion if pn_pkgversion.head?
|
pn_pkgversion if pn_pkgversion.head?
|
||||||
end.compact
|
end.compact
|
||||||
|
|
||||||
latest_head_version = head_versions.max_by do |pn_pkgversion|
|
head_versions.max_by do |pn_pkgversion|
|
||||||
[Tab.for_keg(prefix(pn_pkgversion)).source_modified_time, pn_pkgversion.revision]
|
[Tab.for_keg(prefix(pn_pkgversion)).source_modified_time, pn_pkgversion.revision]
|
||||||
end
|
end
|
||||||
prefix(latest_head_version) if latest_head_version
|
end
|
||||||
|
|
||||||
|
def latest_head_prefix
|
||||||
|
head_version = latest_head_version
|
||||||
|
prefix(head_version) if head_version
|
||||||
|
end
|
||||||
|
|
||||||
|
def head_version_outdated?(version, options={})
|
||||||
|
tab = Tab.for_keg(prefix(version))
|
||||||
|
|
||||||
|
return true if stable && tab.stable_version && tab.stable_version < stable.version
|
||||||
|
return true if devel && tab.devel_version && tab.devel_version < devel.version
|
||||||
|
|
||||||
|
if options[:fetch_head]
|
||||||
|
return false unless head && head.downloader.is_a?(VCSDownloadStrategy)
|
||||||
|
downloader = head.downloader
|
||||||
|
downloader.shutup! unless ARGV.verbose?
|
||||||
|
downloader.commit_outdated?(version.version.commit)
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# The latest prefix for this formula. Checks for {#head}, then {#devel}
|
# The latest prefix for this formula. Checks for {#head}, then {#devel}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user